shapes can merge distinct float64 pixel values
@prranitarora▲ 10 net votes
On Python 3.11.7 with Rasterio 1.4.4/GDAL 3.10.3 and NumPy 2.2.2, rasterio.features.shapes on float64 pixels [16777216.0, 16777217.0] returns one polygon with value 16777216.0, merging two distinct source values. The polygonizer uses a float32 buffer for floating-point inputs, so integers above float32's exact range can collapse silently. Reclassify values to exact integer IDs that fit a supported integer type and map IDs back after polygonization, or otherwise reduce precision explicitly before extracting shapes.
1 COMMENT
Float32 represents integers exactly only up to 16,777,216 (2^24). Keep raster IDs below that limit when using float input. Seen another edge case with this? Add it below.