ThinkGeo.com    |     Documentation    |     Premium Support

Problem with GeoTIFFs

Hi,

we’ve been using ThinkGeo since v9 (with Framework v4.8) and have successfully implemented a tool to show aerial images.
Now I’ve ported this tool to .NET 8 and the ThinkGeo WPF 14.3-beta022. But unfortunately the aerial images cannot be shown anymore.

I’ve tried several approaches:

  1. NativeImageRasterLayer used in v9 now crashes the application when I try to open the layer.
  Exception:	System.NullReferenceException: Object reference not set to an instance of an object.
   at ThinkGeo.Core.GeoImage.get_Width()
   at ThinkGeo.Core.NativeImageRasterSource.oCM=()
   at ThinkGeo.Core.NativeImageRasterSource.OpenCore()
   at ThinkGeo.Core.RasterSource.Open()
   at ThinkGeo.Core.RasterLayer.OpenCore()
   at ThinkGeo.Core.Layer.Open()

This behaviour can be repoduced when I load the TIFF file into a GeoImage and then try to access the With of the image.

  1. GeoTiffRasterLayer does not crash but no image is visible.

  2. UnmanagedGeoTiffRasterLayer does not crash but shows only a black rectangle. It will crash however when I try to change the image.

  3. GeoTiffGdalRasterLayer behaves exacly the same like UnmanagedGeoTiffRasterLayer.

I’ve not changed anything else and the images can be viewed using the old version of the tool with ThinkGeo v9 and NativeImageRasterLayer.

Do you have any ideas how to proceed?
Thank you for your help.

Regards,
Peter

Hi Peter,

NativeImageRasterLayer in V9 is using GDI+ while V14 is using Skia for cross platforms reasons. Any chance you send over the image file (as well as its world file) to us to dig in? You can upload it here or send to support@thinkgeo.com

GeoTiffRasterLayer might not be working because your tiff might not be a geotiff.

Thanks,
Ben

Hi Ben,

I’ve send you an image using mail.
Could you please confirm when it reaches you?
Thank you.

Regards,
Peter

Hi Peter,

No, I haven’t received it. In case that’s a big file, can you share through google drive or something? I see a couple emails from you in sales@thinkgeo.com inbox sent last month, you can send it to both support@thinkgeo.com and sales@thinkgeo.com in case that’s the support@thinkgeo.com box cannot get it through.

Thanks,
Ben

Hi Ben,

it was actually stuck in my mail client. My bad. Sorry.
Please check again. It is about 20 MB.

Thanks,
Peter

No problem, Peter! It went through and we are on it.

Hi Peter,

The issue is recreated and it seems that tiff is not supported by Skia. So I created a new WpfRasterLayer for you which uses the Wpf classes to load the image. It’s for Windows only, and can also be used on Winforms. Pull the latest beta035 and have a try.

Here is the sample code:

   private async void MapView_Loaded(object sender, RoutedEventArgs e)
   {
       // Set the map's unit of measurement to meters(Spherical Mercator)
       MapView.MapUnit = GeographyUnit.Meter;

       // Add Cloud Maps as a background overlay
       var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay
       {
           ClientId = SampleKeys.ClientId,
           ClientSecret = SampleKeys.ClientSecret,
           MapType = ThinkGeoCloudVectorMapsMapType.Light,
           // Set up the tile cache for the ThinkGeoCloudVectorMapsOverlay, passing in the location and an ID to distinguish the cache. 
           TileCache = new FileRasterTileCache(@".\cache", "thinkgeo_vector_light")
       };
       MapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

       var layer = new WpfRasterLayer(@"D:\test\LuBi__301112.tif");
       var layerOverlay = new LayerOverlay();
       layerOverlay.TileType = TileType.SingleTile;
       layerOverlay.Layers.Add(layer);

       layer.Open();
       MapView.CurrentExtent = layer.GetBoundingBox();
       MapView.Overlays.Add(layerOverlay);

       await MapView.RefreshAsync();
   }

and here is what it looks like


Below is what it looks like on QGis by the way:

Thanks,
Ben

Hi Ben,

thank you very much for your fast reaction!!
Now I can see the aerial images again.

There one more thing though: When I set a transparent color like this

layer.KeyColors.Add(new GeoColor(255, 0, 0, 0));

to eliminate the black borders, then the image will not be shown anymore. There’s no error message or exception. It is just not visible anymore. When I remove the line it is shown again.
Would it be possible to re-enable this transparency feature again?

Best regards,
Peter

Hi Peter,

Pull the latest beta038 and it is working now. :slight_smile:

Thanks,
Ben

Hi Ben,

it works!
Thank you!!

Regards,
Peter

That’s awesome! :+1: