I am trying to retrieve information from a GeoTiff using the GDAL API in Python (Spyder). Within Anaconda I have my base environment which contains gdal v2.3.3, but I also created a virtual environment with gdal v3.0.2 since this version of GDAL can read GeoTiffs that can be classified as "BigTiffs" (> 4GB).

When I run 'gdalinfo filename.tif' from the Anaconda terminal within my virtual environment, I get coordinate system information output that starts with:

Coordinate System is: PROJCRS["WGS 84 / UTM zone 16N", BASEGEOGCRS["WGS 84", DATUM["World Geodetic    
System 1984", etc..

I can also obtain this same data when I run 'print(gdal.Info("filename.tif"))' within Spyder which is also configured for my virtual environment:

from osgeo import gdal, osr, ogr
print(gdal.VersionInfo())  # outputs 3000200 (i.e. v3.0.2)
print(gdal.Info('filename.tif'))  # outputs same data as Anaconda terminal

However, when I attempt to obtain GeoTiff information using 'gdal.Open("filename.tif")' within Spyder and invoke other GDAL functions I obtain GeoTiff data that does not appear compatible with gdal v3.0.2:

dem = gdal.Open('filename.tif')
print(dem.GetProjection())  # outputs PROJCS["WGS 84 / UTM zone 16N",GEOGCS["WGS 84", etc...

For the "GetProjection()" function, for example, I need the output to show "PROJCRS" and not "PROJCS". I need the GDAL commands within Spyder to be compatible with v3.0.2, but they seem to be returning outputs compatible with v2.3.3. Is there something else I may be missing when invoking the GDAL API?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.