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!

The issues you have found earlier (filed as IMAGINGNET-4775) have been fixed in this update.

Hi Evgeniy.Timofeev,
I finally had a change to give this a whirl and admit I’m a bit confused. I have a project with a reference to the Aspose.GIS package and nothing else. I’ve upgraded that package to version 21.10 and am seeing the same results. I see that there was a fix in the Aspose.Imaging … so I pulled in that package and now receive an error much earlier in the code:

|▶|InnerException|{“Could not load type ‘Aspose.Imaging.InjectForGis’ from assembly ‘Aspose.Imaging, Version=21.10.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’.”:“Aspose.Imaging.InjectForGis”}|System.Exception {System.TypeLoadException}|"

Any thoughts?

AsposeGISTakeTwo.zip (604.7 KB)

If it makes things easier, attached is a simpler example of one thing I’m trying to do - take a satellite image and render a map. I’d love it if we could get this working.

Hi @msmearer

Thank you for sharing additional details. We will test IMAGINGNET-4775 task using your attached project.

The IMAGINGNET-4775 task has been fixed. But the GeoTIFF implementation uses both Aspose.Gis and Aspose.Imaging products so we need to include the IMAGINGNET-4775 code in Aspose.Gis to complete fixing.

Got it - thank you.