[gdal-dev] Lost in decimals... geotransform in python 2.7

Nicolas Cadieux nicolas.cadieux at archeotec.ca
Sun Dec 9 08:42:27 PST 2018


Hi,

I am trying to get the four corners of a raster the size of Canada (very 
big therefore decimals count).  If I get the geotransform, I get:

geotransform: (-132.00041666666667, 0.0008333333333333334, 0.0, 
53.000416666666666, 0.0, -0.0008333333333333334)
In Python 2.7:
print (geotransform[0]) ->               -132.000416667
print float(geotransform[0]) ->       -132.000416667
print str(geotransform[0]) ->           -132.000416667
print Decimal(geotransform[0]) -> 
-132.000416666666666287710540927946567535400390625
In Qgis3x (on Windows64), I get:    -132.0004166666666663 in the layer 
properties.
Qgis looks like the end result of:
getcontext().prec = 19
print Decimal(geotransform[0])/Decimal(1)

Must I use "Decimals" to deal with the geotransform output? Using float 
will truncate the decimal place and I may end up with an extra pixel row 
or column because of the size of the raster. So what is the proper way 
to work with this?

Thanks
Nicolas


More information about the gdal-dev mailing list