Re: A question about the rasterio precision & python floats (Pixel width & height)

Sean Gillies


On Mon, May 25, 2020 at 3:30 AM <thomaswanderer@...> wrote:

When opening my raster with QGIS, I can see the Pixel Size of my raster as:


When I read he same raster with rasterio, I get pixel size values with a lower precision and I guess this causes some problems when calculating new affines for another extent

0.0008333333299974727 0.0008333333300202157

I have tries to pass the decimal_precision=X when opening my raster with rasterio, but this has no effect. I guess this is a general float problem on my system. My suggestion therefore would be to use python Decimals or any other type representing real floats.

QGIS and rasterio both use GDAL to read raster data and all of these use double precision floats to store values of the georeferencing matrix. I believe you're seeing different string representations of the same numbers. Since the hex representations of the two numbers are the same, I suspect the values shown by QGIS are overly precise and that the last digits are meaningless.

>>> 0.0008333333299974727193.hex()
>>> 0.0008333333299974727.hex()

Sean Gillies

Join to automatically receive all group messages.