We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Difficulty Working with Satellite GeoTiffs

I am looking to work with GeoTiff files downloaded from common satellite imagery sources (LandSat, Sentinel, Planet). So far, I’ve not had any luck using Aspose.GIS - am I missing something?

I always get an error calling layer.GetStatistics(). I get the same error when trying to render a map, too. Any help is most appreciated! It looks like such a great library - I’d love to use it.

Thank you!

Sample Images:
SatImages.zip (784.3 KB)

The code:

String dataDirectory = "C:\\Users\\someuser\\Documents\\GIS\\";
String licensePath = Path.Combine(dataDirectory, "Aspose.GIS.NET.lic");
String geoTiffPath = Path.Combine(dataDirectory, "Images", "SentinelNDVI.tif");

var license = new License();
license.SetLicense(licensePath);

using RasterLayer layer = Drivers.GeoTiff.OpenLayer(geoTiffPath);

IRasterCellSize cellSize = layer.CellSize;
Extent extent = layer.GetExtent();
SpatialReferenceSystem spatialRefSys = layer.SpatialReferenceSystem;
String code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString();
RasterRect bounds = layer.Bounds;
Int32 bandCount = layer.BandCount;

Console.WriteLine($"cellSize: {cellSize}");
Console.WriteLine($"extent: {extent}");
Console.WriteLine($"spatialRefSys: {code}");
Console.WriteLine($"bounds: {bounds}");
Console.WriteLine($"bandCount: {bandCount}");

// read and print bands
for (Int32 i = 0; i < layer.BandCount; i++)
{

    BandTypes dataType = layer.GetBand(i).DataType;
    Boolean hasNoData = !layer.NoDataValues.IsNull();
    RasterStatistics statistics = layer.GetStatistics(i);

    Console.WriteLine();
    Console.WriteLine($"Band: {i}");
    Console.WriteLine($"dataType: {dataType}");
    Console.WriteLine($"statistics: {statistics}");
    Console.WriteLine($"hasNoData: {hasNoData}");

    if (hasNoData)
    {
        Console.WriteLine($"noData: {layer.NoDataValues[i]}");
    }

}

The error:

System.ArgumentException
  HResult=0x80070057
  Message=Destination array was not long enough. Check the destination index, length, and the array's lower bounds. (Parameter 'destinationArray')
  Source=System.Private.CoreLib
  StackTrace:
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at Aspose.Imaging.BufferHelper.CopyIList[T](IList`1 sourceBuffer, Int32 sourceIndex, IList`1 destinationBuffer, Int32 destinationIndex, Int32 length)
   at Aspose.Imaging.FileFormats.Tiff.Codecs.Tile.TileHelper.ShiftTileData(IList`1 tileData, Rectangle tileArea, RawDataSettings rawDataSettings, TiffCodec codec)
   at Aspose.FileFormats.Tiff.Codecs.Readers.Processors.SimpleCompressReader.TilePartialRawDataLoader.LoadChunkyData(Int32 tileIndex, Int32 x, Int32 y, Rectangle tileArea)
   at Aspose.FileFormats.Tiff.Codecs.Readers.Processors.SimpleCompressReader.TilePartialRawDataLoader.Load(Int32 tileIndex, Int32 x, Int32 y, Rectangle tileArea)
   at Aspose.Imaging.FileFormats.Tiff.Codecs.Tile.TileRawDataProcessor.Execute(Rectangle areaToProcess, ITileRawDataLoader tileLoader)
   at Aspose.FileFormats.Tiff.Codecs.Readers.Processors.SimpleCompressReader.TilePartialRawDataLoader.Process(Rectangle areaToProcess)
   at Aspose.Imaging.PartialProcessor.ProcessWithSmartPartialProcessor(IPartialSmartProcessor partialProcessor, IList`1 areas, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.PartialProcessor.Process(Rectangle areaToProcess, IPartialProcessor partialProcessor, ProcessingType processingType, Int32 fullWidth, Int32 fullHeight, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.PartialProcessor.Process(Rectangle areaToProcess, IPartialProcessor partialProcessor, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.FileFormats.Tiff.Codecs.Readers.TiffSimpleCompressReader.Decode(TiffStreamReader stream, Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)
   at Aspose.Imaging.FileFormats.Tiff.TiffDataReader.LoadRawData(Rectangle rectangle, RawDataSettings destRawDataSettings, IPartialRawDataLoader rawDataLoader)
   at Aspose.Imaging.PartialRawDataLoader.Process(Rectangle areaToProcess)
   at Aspose.Imaging.PartialProcessor.ProcessWithBasePartialProcessor(IPartialProcessor partialProcessor, IList`1 areas, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.PartialProcessor.Process(Rectangle areaToProcess, IPartialProcessor partialProcessor, ProcessingType processingType, Int32 fullWidth, Int32 fullHeight, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.PartialProcessor.Process(Rectangle areaToProcess, IPartialProcessor partialProcessor, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.InternalRasterImageLoaderLicensed.LoadRawData(Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader partialRawDataLoader)
   at Aspose.Imaging.RasterImage.LoadRawData(Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)
   at Aspose.Imaging.FileFormats.Tiff.TiffImage.TiffActiveFrameLoader.LoadRawData(Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)
   at Aspose.Imaging.PartialRawDataLoader.Process(Rectangle areaToProcess)
   at Aspose.Imaging.PartialProcessor.ProcessWithBasePartialProcessor(IPartialProcessor partialProcessor, IList`1 areas, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.PartialProcessor.Process(Rectangle areaToProcess, IPartialProcessor partialProcessor, ProcessingType processingType, Int32 fullWidth, Int32 fullHeight, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.PartialProcessor.Process(Rectangle areaToProcess, IPartialProcessor partialProcessor, IProgressEventHandler progressEventHandler)
   at Aspose.Imaging.InternalRasterImageLoaderLicensed.LoadRawData(Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader partialRawDataLoader)
   at Aspose.Imaging.RasterImage.LoadRawData(Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)
   at   . (RasterRect , RasterReadExpression )
   at   . (RasterReadExpression )
   at   .()
   at   .     (RasterRect , RasterReadExpression )
   at Aspose.Gis.Raster.RasterLayer.GetValuesOnExpression(RasterRect rect, RasterReadExpression expression)
   at Aspose.Gis.Raster.RasterStatistics.(RasterLayer , Int32 , Boolean )
   at Aspose.Gis.Raster.RasterLayer.GetStatistics(Int32 bandIndex, Boolean excludeNodataValue)

Hi, @msmearer

We have reproduced this problem and created a ticket GISNET- 1288 . Looks like a problem have occurred for GeoTiff with tiled structure. We will notify you here as we will have progress with it.

Please let me know if you experience any other problems.

Thank you Evgeniy.Timofeev!