"TIFF file is missing a required tag StripOffsets" 使用 class "GeotiffReader"

"TIFF file is missing a required tag StripOffsets" when working with a class "GeotiffReader"

有这样一个问题:使用一些*.tiff,当试图使用NASA WorldWind库class GeotiffReader中的readDataRaster()方法获取DataRaster[]时,抛出异常:

ERROR j.l.Throwable - java.io.IOException: TIFF file is missing a required tagStripOffsets

下面是使用 *.tiff 的代码。 代码:

private GeotiffReader reader;
private ByteBufferRaster raster;
...
reader = new GeotiffReader(file);
listDataRaster.add(reader.readDataRaster());
...
DataRaster[] dataRaster = listDataRaster.get(iter);
raster = (ByteBufferRaster)dataRaster[0];
...
raster.setDoubleAtPosition(y, x, value);

错误发生在行:

listDataRaster.add(reader.readDataRaster()); 

该方法尝试 return DataRaster[] 并给出上述错误。

我的任务是获取 *.tiff ByteBufferRaster,然后在一些计算后使用 setDoubleAtPosition 对网格进行更改并重写 *.tiff。我该如何解决这个错误?如果没有,还有其他方法可以完成我的任务吗?

谢谢大家,我们要求通过ExtendedGDALDataRaster这样解决

DataRasterReaderFactory readerFactory = (DataRasterReaderFactory) WorldWind
                .createConfigurationComponent(AVKey.DATA_RASTER_READER_FACTORY_CLASS_NAME);
DataRasterReader dataRasterReader;
DataRaster[] dataRasters = null;
...
dataRasterReader = readerFactory.findReaderFor(file, null);
dataRasters = dataRasterReader.read(file, null);
...
rasterGdal = (ExtendedGDALDataRaster) dataRasters[0];

ElevationModel elevationModelFromGlobe = GLOBE.getElevationModel(); 
Sector boundingSector = rasterGdal.getSector();
int[] heightAndWidth = new int[2];  

// Method for creating an empty sector by analogy with the current one  
recalculationHeightAndWidth (boundingSector, elevationModelFromGlobe, heightAndWidth);


// Method to create default parameters for the sector
AVList params = getParams(boundingSector, heightAndWidth[1], heightAndWidth[0]);
raster = (ByteBufferRaster) ByteBufferRaster.createGeoreferencedRaster(params);

Dataset dataset = rasterGdal.getBestSuitedDataset(heightAndWidth[1], heightAndWidth[0], rasterGdal.getSector());
band = dataset.GetRasterBand(1);

然后你可以从 *.tiff 中获取任何点的高度值并根据你的判断更改它(它将在数据中)

float[] data = new float[1];
band.ReadRaster(x, y, 1, 1, band.getDataType(), data);