{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Working With Horizons","description":"Accelerate E&P application development and protect your innovation by consuming our Data and Domain APIs / Platform APIs.","lang":"en-US","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"working-with-horizons","__idx":0},"children":["Working With Horizons"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"working-with-horizon-data","__idx":1},"children":["Working With Horizon Data"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Note"]},": You will need to include HorizonData to your ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Module Dependencies"]}," list."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"loading-a-horizon-from-a-file","__idx":2},"children":["Loading a horizon from a file"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["We load an horizon called filename and print the access keys' name and range. If your application requires a file chooser for selecting the horizon file, you can use the one provided with INTViewer. See section ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Using the Horizon File Chooser"]}," below for an example."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    import com.interactive.intviewerapi.data.IData;\n    import com.interactive.intviewerapi.data.horizon.IHorizonData;\n    import com.interactive.intviewerapi.data.horizon.IHorizonDataCollection;\n    ...\n    try {\n        IHorizonDataCollection hd = IData.factory.createNewInstance(filePath, IHorizonDataCollection.class);\n    } catch (Exception ex) {\n        DialogManager.getDefault().showMessageDialog(\"Error loading horizon: \" + filePath,\n         \"Error Loading Horizon\", DialogManager.ERROR);\n        return;\n    }\n      for (IHorizonData shd: hd.getAllHorizonData()){\n         List<IKeyRange> klist = shd.getDataRange();\n         for (IKeyRange kr:klist) {\n             System.out.println(kr);\n         }\n     }\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Internally, the default factory uses Netbeans FileObject and DataObject to load the horizon. Netbeans filesystem supports the notion of a data pool, so that if you open several times the same file, you will get the same data object instance."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"using-the-horizon-file-chooser","__idx":3},"children":["Using the horizon file chooser"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This example shows how to let a user select a horizon file using the built-in horizon file selection dialog in INTViewer. The chooser is automatically setup to filter valid horizon filenames."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To select one dataset:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"   import com.interactive.intviewerapi.data.ISingleDataChooser;\n   // get the chooser for horizon data type\n   ISingleDataChooser<IHorizonDataCollection> singleChooser = ISingleDataChooser.Factory.createNewInstance(IDataChooser.HORIZON);\n   // popup the chooser dialog\n   int rc = singleChooser.setDataChooserVisible(true);\n   if (rc == JFileChooser.APPROVE_OPTION) {\n      IHorizonDataCollection horizonData = singleChooser.getSelectedData();\n   }\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To select multiple datasets:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"   import com.interactive.intviewerapi.data.IMultipleDataChooser;\n   // get the file chooser for horizon data type\n   IMultipleDataChooser<IHorizonDataCollection> multipleChooser = IMultipleDataChooser.Factory.createNewInstance(IDataChooser.HORIZON);\n   // popup the chooser dialog\n   int rc = multipleChooser.setDataChooserVisible(true);\n   if (rc == JFileChooser.APPROVE_OPTION) {\n      for (IHorizonDataCollection sdata : multipleChooser.getSelectedData()) {\n      }\n   }\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"getting-information-about-the-data-keys","__idx":4},"children":["Getting information about the data keys"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Range keys provide information about how to access the horizon data. They can be accessed as follows:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["List<IKeyRange>"]}," keyRangeList = hd.getDataRange();"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Unlike in seismic datasets, the last key of a horizon dataset is usually NOT the time key as it is a non-indexed attribute. The key names of a horizon are typically INLINE and XLINE. Time, Amplitude are usually non-indexed attributes."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"creating-a-new-horizon-from-scratch","__idx":5},"children":["Creating a new horizon from scratch"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["We create a horizon with two access keys (INLINE and XLINE) and two non-indexed attribute fields (Time and Amplitude)."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    import com.interactive.intviewerapi.data.horizon.HorizonUtil;\n    import com.interactive.intviewerapi.data.FieldDesc;\n    ...\n    IHorizonData hd = HorizonUtil.createHorizonData(\"tmp\",\n        new FieldDesc[]{\n            new FieldDesc(\"INLINE\", 0, true),\n            new FieldDesc(\"XLINE\", 1, true),\n            new FieldDesc(\"Time\", 2),\n            new FieldDesc(\"Amplitude\", 3)\n        });\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["There is no limit in terms of the number of access keys or attributes that you can specify."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"adding-points","__idx":6},"children":["Adding points"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following example shows how to populate the empty horizon created in the previous section."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    import com.interactive.intviewerapi.data.PointData;\n    ...\n    for (int inline= 0; inline < 400; inline++) {\n        for (int xline = 0; xline < 400;  xline++) {\n            PointData pd = hd.createPointData();\n            pd.setValues(new float[] {inline, xline,\n                inline*0.1f, (xline+inline)*13.45f});\n            hd.addPointData(pd);\n        }\n    }\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each time a point is added, a PointDataEvent is sent. This can cause performance issues when a large number of points has to be added. Wrap this code inside a IHorizonData.update method to reduce the event overhead."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    hd.update(new Runnable() {\n       @Override\n       public void run() {\n          for (int inline= 0; inline < 400; inline++) {\n             for (int xline = 0; xline < 400;  xline++) {\n                PointData pd = hd.createPointData();\n                pd.setValues(new float[] {inline, xline,\n                   inline*0.1f, (xline+inline)*13.45f});\n                hd.addPointData(pd);\n             }\n          }\n       }\n    });\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"deleting-points","__idx":7},"children":["Deleting points"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["We delete all the points within INLINE 20-21 and XLINE 30-31."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    import com.interactive.intviewerapi.data.IPointSelection;\n    import com.interactive.intviewerapi.data.KeyRange;\n    import com.interactive.intviewerapi.data.query.RangeQuery;\n    ...\n    RangeQuery rq = new RangeQuery();\n    rq.addKeyRange(new KeyRange(\"INLINE\", 20, 21 ));\n    rq.addKeyRange(new KeyRange(\"XLINE\", 30, 31 ));\n    IPointSelection ps = hd.select(rq);\n    hd.delete(ps);\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"querying-points","__idx":8},"children":["Querying points"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["We retrieve all the points for INLINE 40."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    RangeQuery rq = new RangeQuery();\n    rq.addKeyRange(new KeyRange(\"INLINE\", 40, 40 ));\n    IPointSelection ps = hd.select(rq);\n    List<PointData> dataList = ps.getData();\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"saving-a-horizon","__idx":9},"children":["Saving a horizon"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You could do the following to save a horizon:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    ISingleDataSaver ds = ISingleDataSaver.Factory.createNewInstance(IDataChooser.HORIZON);\n    if (ds.setDataSaverVisible(true, horzData.getDataPath(), horzData) == JFileChooser.APPROVE_OPTION) {\n        HorizonDataCollection savingHorizons = HorizonUtil.createHorizonDataCollection(\"temp\");\n        savingHorizons.addHorizonData(horzData);\n        FileObject fo = (FileObject) ds.saveDataAndWait(savingHorizons);\n        if (fo != null) {\n            String absoluteDataPath = FileUtil.toFile(fo).getAbsolutePath();\n            if (horzData.getDataPath() == null || horzData.getDataPath().length() == 0) {\n                horzData.setDataPath(absoluteDataPath);\n            }\n        }\n    }\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This would display a dialog to let the users select the fileName in which they want to save the IHorizonData."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Note: in your project module properties, you will need to include File System API to your ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Module Dependencies"]}," list."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"horizon-data-and-horizon-data-collection","__idx":10},"children":["Horizon Data and Horizon Data Collection"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This example shows how to extract a single IHorizonData object out of an IData object that could be IHorizonData or IHorizonDataCollection."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"if (data instanceof IHorizonData) {\n   return (IHorizonData) data;\n} else if (data instanceof IHorizonDataCollection) {\n   IHorizonData currentData = null;\n   if (data.getDataName() != null) {\n      currentData = ((IHorizonDataCollection) data).getHorizonData(data.getDataName());\n   }\n   if (currentData == null) {\n      currentData = ((IHorizonDataCollection) data).getAllHorizonData()[0];\n   }\n   return (IHorizonData) currentData;\n} else {\n   return null;\n}\n"},"children":[]}]},"headings":[{"value":"Working With Horizons","id":"working-with-horizons","depth":1},{"value":"Working With Horizon Data","id":"working-with-horizon-data","depth":2},{"value":"Loading a horizon from a file","id":"loading-a-horizon-from-a-file","depth":3},{"value":"Using the horizon file chooser","id":"using-the-horizon-file-chooser","depth":3},{"value":"Getting information about the data keys","id":"getting-information-about-the-data-keys","depth":3},{"value":"Creating a new horizon from scratch","id":"creating-a-new-horizon-from-scratch","depth":3},{"value":"Adding points","id":"adding-points","depth":3},{"value":"Deleting points","id":"deleting-points","depth":3},{"value":"Querying points","id":"querying-points","depth":3},{"value":"Saving a horizon","id":"saving-a-horizon","depth":3},{"value":"Horizon Data and Horizon Data Collection","id":"horizon-data-and-horizon-data-collection","depth":3}],"frontmatter":{"title":"Working With Horizons","pageId":"intviewer-apis-for-data/working-with-horizons","seo":{"title":"Working With Horizons"}},"lastModified":"2026-10-22T14:32:05.575Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/intviewer/intviewer-apis-for-data/working-with-horizons","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}