简体   繁体   English

使用类“GeotiffReader”时,“TIFF 文件缺少必需的标签 StripOffsets”

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

There was such a problem: working with some * .tiff, when trying to get DataRaster [] using the readDataRaster () method in the NASA WorldWind library class GeotiffReader, an exception is thrown:出现了这样一个问题:使用一些*.tiff,尝试使用NASA WorldWind库类GeotiffReader中的readDataRaster()方法获取DataRaster[]时,抛出异常:

ERROR jlThrowable - java.io.IOException: TIFF file is missing a required tagStripOffsets错误 jlThrowable - java.io.IOException: TIFF 文件缺少必需的 tagStripOffsets

Below is the code that works with * .tiff.下面是使用 * .tiff 的代码。 Code:代码:

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);

The error occurs in the line:错误发生在以下行中:

listDataRaster.add(reader.readDataRaster()); 

The method tries to return a DataRaster[] and gives the above error.该方法尝试返回 DataRaster[] 并给出上述错误。

My task is to take the * .tiff ByteBufferRaster and then use setDoubleAtPosition to make changes to the grid after some calculations and rewrite * .tiff.我的任务是获取 * .tiff ByteBufferRaster,然后使用 setDoubleAtPosition 在一些计算后更改网格并重写 * .tiff。 How do I fix this error?我该如何解决这个错误? And if not, are there other ways to accomplish my task?如果没有,还有其他方法可以完成我的任务吗?

Thank you all, we demand to solve this way via ExtendedGDALDataRaster谢谢大家,我们要求通过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);

And then for you can get the value of the height of any point from * .tiff and change it to your discretion (it will be in data)然后因为您可以从 * .tiff 中获取任何点的高度值并将其更改为您的判断(它将在数据中)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM