# Indexing Seismic Data

### Indexing one seismic file

The example below is the simplest way to index seismic data.

```
ISeismicData seismicData = IData.factory.createNewInstance("F:\\Data\\Segy\\Attributes\\cdp_stack.sgy", ISeismicData.class);
ISeismicIndexer indexer = ISeismicIndexer.Factory.getInstance(seismicData);
indexer.index(new ILongTaskProgressMonitor.NullProgressMonitor());
```

See [Working with Long Tasks](/solutions/intviewer/other-useful-intviewer-apis/working-with-long-tasks) to show a progress bar from a progress monitor. If you just need to follow the progress for debugging purposes, substitute the last line with:

```
indexer.index(new ILongTaskProgressMonitor.NullProgressMonitor() {
   @Override
   public void progress(int i) {
      System.out.println(i);
    }
 });
```

This example assumes that:

- the format of the raw segy file follows the Segy standard exactly when it comes to header offsets,
- the dataset should be indexed as a volume, with INLINE and XLINE being the volume keys.
- the dataset in is time


Also , It doesn't assign an EPSG code and it doesn't attempt to calculate:

- the outline of the dataset,
- the corner point geometry


In real life situations, a command line to index a seismic dataset has many more options:

```
cd /d "C:\Program Files\INT\INTViewer\scripts"
SET CLASSPATH=../intviewer/modules/ext/SeismicDataAdapter.jar
SET CLASSPATH=%CLASSPATH%;../intviewer/modules/ext/jseismic.jar
SET CLASSPATH=%CLASSPATH%;../intviewer/modules/ext/int_util.jar
"C:\Program Files\Java\jdk1.8.0_102\jre\bin\java" -cp %CLASSPATH%  -Xms48m -Xmx2g com.interactive.seismicDataAdapter.indexingAdapter.indexing.BuildIndex ^
    -segys="cdp_stack.sgy" -basepath="F:\Data\Segy\attributes" ^
    -xgy="F:\Data\Segy\attributes\cdp_stack.xgy" -index="F:\Data\Segy\attributes\cdp_stack.igx" -merge=N ^
    -keys="INLINE;XLINE" -volumekeys="INLINE;XLINE" -indextype=VOLUME -sampleunit=s ^
    -epsgcode="32056:unknown" -calculatexygeometry=Y -xykeys="CDPX;CDPY" -xymultiplier="LOC SCALER"  ^
    -calculateoutline=Y -maxoutlinepolygons=1000 -samplerate="Use Header Value" -endian=B ^
    -indexformat=auto -maxitems=200000 -pagesize=1024 -tmpbuffersize=65536 -indexbuffersize=32768 ^
    -segyFormat="F:\Data\Segy\attributes\cdp_stack.xml" ^
    -tmppath="C:\Users\thierry.danard\AppData\Roaming\.intviewer\5.2"
```

The matching java code would be:

```
ISeismicData seismicData = IData.factory.createNewInstance("F:\\Data\\Segy\\Attributes\\cdp_stack.sgy", ISeismicData.class);
ISeismicIndexer indexer = ISeismicIndexer.Factory.getInstance(seismicData);
indexer.setOutputFilePath("F:\\Data\\Segy\\attributes\\cdp_stack.xgy");
indexer.setMergeIndexFiles(false);
List keyNames = new ArrayList<>();
keyNames.add("INLINE");
keyNames.add("XLINE");
indexer.setKeyNames(keyNames);
indexer.setVolumeKeyNames("INLINE", "XLINE");
indexer.setIndexType(ISeismicIndexer.VOLUME_INDEX_TYPE);
indexer.setEPSGCode("32056:unknown");
indexer.setCalculateXyGeometry(true);
indexer.setCalculateOutline(true);
indexer.setXyFieldNames("CDPX", "CDPY");
indexer.setXyMultiplierFieldName("LOC SCALER");
indexer.setXyMultiplierType(ISeismicIndexer.USE_HEADER_MULTIPLIER_TYPE);
indexer.setMappingFilePath("F:\\Data\\Segy\\Attributes\\cdp_stack.xml");
```

The "sampleunit" is derived automatically from the ISeismicData.getZUnit() method of the specified datasets.

See [ISeismicIndexer](/solutions/intviewer/api-reference) for the complete API of the ISeismicIndexer interface.

### Indexing multiple seismic files

The API to index multiple files uses the getInstance() method with a set of datasets instead of just one.

```
ISeismicData seismicData1 = IData.factory.createNewInstance("F:\\Data\\Segy\\Attributes\\cdp_stack_1.sgy", ISeismicData.class);
ISeismicData seismicData2 = IData.factory.createNewInstance("F:\\Data\\Segy\\Attributes\\cdp_stack_2.sgy", ISeismicData.class);
ISeismicIndexer indexer = ISeismicIndexer.Factory.getInstance(seismicData1, seismicData2);
```

### Performance considerations

The indexer API can only be used to perform indexing tasks in INTViewer, meaning that INTViewer needs to be running while the indexing is being performed. For large datasets, this is not practical as the execution time can take hours and even days in rare cases. Customers typically generate an indexing command line and execute that command line instead. The ISeismicIndexer interface should only be used for small datasets.