ThinkGeo.com    |     Documentation    |     Premium Support

Problematic TIF shows up black and wrong coordinates

Hi,

We have a problematic TIF file on our hands. Other map software seem to open it correctly but ThinkGeo has difficulties interpreting it. The image is shown fully black and also the projection (EPSG:3071 - NAD83(HARN) / Wisconsin Transverse Mercator) goes wrong. QGIS shows the compression as empty.

Interestingly the image is shown correctly when re-recreating the file with the (seemingly) same content.

As I’m a bit hesitant to pass the file publicly, can I send it to someone with email? It’s only 4MB in size.

Best Regards,
Jarno

Hi Jarno,

Just send the tif to support@thinkgeo.com and we’ll take a look at it.

Thanks,
John

1 Like

Hi Jarno,

For a little more background, what are you referring to in the quote below?

How are you ‘recreating’ the file successfully? Are you using ThinkGeo to create the file and if so, what code are you using?

Thanks,
John

Hi Jarno,

There are some Tiff files that our standard GeoTiffRasterLayer does not support. But we have additional support in our UnmanagedGeoTifffRasterLayer. I’ve put together the following sample which displays your file properly:
// It is important to set the map unit first to either feet, meters or decimal degrees.
mapView.MapUnit = GeographyUnit.Meter;

        OpenStreetMapOverlay osmMapsOverlay = new OpenStreetMapOverlay("test123");
        mapView.Overlays.Add(osmMapsOverlay);

        // Create a new overlay that will hold our new layer and add it to the map.
        LayerOverlay layerOverlay = new LayerOverlay();
        layerOverlay.TileType = TileType.SingleTile;
        mapView.Overlays.Add(layerOverlay);

        // Create the new layer and dd the layer to the overlay we created earlier.
        UnmanagedGeoTiffRasterLayer geoTiffRasterLayer = new UnmanagedGeoTiffRasterLayer("../../../Data/GeoTiff/sand creek sales.tif");

        ProjectionConverter projectionConverter = new UnmanagedProjectionConverter(3071, 3857);
        geoTiffRasterLayer.ImageSource.ProjectionConverter = projectionConverter;

        layerOverlay.Layers.Add(geoTiffRasterLayer);

        // Set the map view current extent to a slightly zoomed in area of the image.
        geoTiffRasterLayer.Open();
        mapView.CurrentExtent = geoTiffRasterLayer.GetBoundingBox();
        
        // Refresh the map.
        mapView.Refresh();

And a screenshot of the results are below:

Thanks,
John

Hi John,

We can see that the UnmanagedGeoTiffRasterLayer would help with this particular file. However there seems to be an issue of inverted colors when using it for some other TIF files which do work with the normal GeoTiffRasterLayer. Do you have any advice on how to come up with a general solution for all rasters? Do we need to detect the need for different layer classes somehow from the given files?

Regards,
Jarno

Hi Jarno,

I’m sorry, but different Tiff files may render better on the Unmanaged library and some may render better on the managed. There are many different combinations of datasets and it’s hard to programmatically know which one will handle better under which library.

If you pull the latest 13.1 beta build of ThinkGeo.Core from Nuget, there is a new property named: ThinkGeo.Core.LibTiff.TiffType This property may give you some hints on which TiffTypes work better under which library. However, it’ll still take some trial and error with the different Tiff files before you see a pattern and start to have an idea on which types will perform better with which library.

Thanks,
John

Hi John,

We looked at the new TiffType enumeration but we don’t really understand how to use it. The content looks strange with values such as BYTE, SHORT, LONG, etc. We were kind of expecting to see a method which tries to look into a content and return with the information if it was able to determine is the content for example GeoTIFF or something else. We are looking into it ourselves but please let us know if you have something like that and we just don’t know about it.

Thanks,
Jarno

Hi Jarno,

Sorry, but I don’t have much experience with the LibTiff library. I think their documentation will be the best source to try and determine which Tiffs will work better than others.

Thanks,
John

Hi Jarno,

I wanted to check in and see if you had any luck with the LibTiff docs? Or did you find a better solution to determine which library would render each individual dataset the best?

Let me know if you’re still having issues and we can try to help.

Thanks,
John

Hi John,

There’s still a problem with the colors getting inverted when using UnManagedGeoTiffRasterLayer but we are using both implementations. We created a custom way of determining if we are dealing with a GeoTiff or a regular by using the Tiff class from LibTiff to check if a file has a GeoKeyDirectory in its tag list.

However, I actually just noticed the ThinkGeo.Core.LibTiff namespace is missing from the 13.1.0 stable version while the 13.1.0-beta030 still had it. Do you know was it only moved to somewhere else or dropped altogether?

Thanks,
Jarno

Hi Jarno,

I’m glad you found a solution to use both implementations based on the GeoKeyDirectory. That sounds like a good solution. It’s always tricky determining which library to use with which dataset since there is so much variability in the data.

Regarding the LibTiff library in NuGet, thanks for noticing this. I talked to the product team and they will be adding it back to the builds tomorrow. In the mean-time, you can also use the extensions from 13.0 as they did not change with 13.1.

Thanks,
John

1 Like