ThinkGeo.com    |     Documentation    |     Premium Support

Get Bounds From GeoTiff Header

Hi,

I have some user that have GeoTiff files that include the bounds in the file metadata. Is there a way to query the file for extents and apply them to the layer? Up until now I have been requiring users to provide a world file.

Also, would same method allow for using the skew parameters of the world file?

Thanks,
Damian

Thanks Damian,
You can try with

   GeoTiffRasterLayer geoTiffRasterLayer = new GeoTiffRasterLayer("../../../Data/GeoTiff/World.tif");
            geoTiffRasterLayer.Open();
            var hasBBX = geoTiffRasterLayer.HasBoundingBox;
            if (hasBBX)
            {
                var x = geoTiffRasterLayer.GetBoundingBox();
            }

GetBoundingBox will auto read the boundingbox information.

Thanks

Frank

Hi Frank,

That seems to work okay, but I’m having a few other troubles in that I want to reproject the layer.

I’ve tried the following:

var y = layer.GetProjectionText();
layer.ImageSource.Projection = new Proj4Projection(y, 28350);

However, this clears the bounding box and subsequently produces an error. Once a layer is created, there is no way to assign the bounding box. So not sure what to do next.

Thanks,
Damian

Thanks Damian,
I don’t full understand this one. What are you doing is correct. We may need check the projection text first.

So you could try with
if(worldImageLayer.HasProjectionText)
{

}

Also console the value of y. Make sure it is a correct projection string. I you could send us the tif file set(include the twf file) and sample project that will be very helpful for us to understand the issue.

Thanks

Frank