GDAL's Python wrappers don't load correct asc header informaton

by R. M. Spies   Last Updated August 13, 2019 20:22 PM

I have a Python script that I am using to load .asc raster files and then work with the contents therein. However, it isn't loading the correct information that is specified in the headers. The .asc file that I am using has the following for headers:

ncols        2131
nrows        2220
xllcorner    670813.505443912582
yllcorner    5480455.007973534055
cellsize     3.000109992417

But when I run the following simple script to obtain the values of xllcorner, yllcorner, and cellsize:

from osgeo import gdal

dempath = 'My_DEM.asc'
dem_file = gdal.Open(dempath)
dem_transform = dem_file.GetGeoTransform()
print(dem_transform)

I get the following as output:

(670813.5054439126, 3.000109992417, 0.0, 5487115.2521567, 0.0, -3.000109992417)

So as we can see, the yllcorner value that is loaded from the asc file isn't 5480455.007973534055, or any rounding off of it, that I would expect it to be. Instead I am getting 5487115.2521567, which is far off enough that it causes problems for me later on. I can import the correct header information with a variety of ways that are not using the GDAL Python wrappers, but ideally I'd like to keep using the GDAL Python wrappers. Is there something special I am forgetting to specify in my script like projection information? Is this a known bug in GDAL? How can I resolve this issue without having to write my own asc file parser?



Related Questions


Updated February 21, 2019 10:22 AM

Updated June 08, 2015 09:09 AM

Updated February 06, 2018 18:22 PM

Updated February 28, 2019 14:22 PM

Updated July 28, 2017 20:22 PM