Opened 8 years ago

Closed 7 months ago

#4516 closed enhancement (wontfix)

polygonize: add option to avoid rounding of values in float rasters

Reported by: lutra Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: Utilities Version: unspecified
Severity: normal Keywords:
Cc:

Description

That's it, the result would be a grid where every polygon had an attribute with the exact value of the underlying float raster.

Attachments (1)

gdal_polygonize.py (6.7 KB) - added by Flewellyn 3 years ago.
Modified gdal_polygonize.py

Download all attachments as: .zip

Change History (4)

comment:1 Changed 4 years ago by Jukka Rahkonen

It seems that gdal_polygonize.py https://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/scripts/gdal_polygonize.py is calling GDAL algorithm gdal.polygonize as

gdal.Polygonize( srcband, maskband, dst_layer, dst_field, options, callback = prog_func )

From https://trac.osgeo.org/gdal/browser/trunk/gdal/alg/polygonize.cpp I can read that there exists an variant "GDALFPolygonize()" which seems to do what is desired in this ticket:

  • The source pixel band values are read into a 32bit float buffer. If you want
  • to use a (probably faster) version using signed 32bit integer buffer, see
  • GDALPolygonize().

If I am right we could close this ticket as fixed because "GDALFPolygonize()" exists. However, most users run polygonize throught gdal_polygonize.py and it does not mention anything about this option. Also the comments in polygonize.cpp give more information about the usage than http://www.gdal.org/gdal_polygonize.html even the latter does have a link to the doxygen document of the algorithm.

Changed 3 years ago by Flewellyn

Attachment: gdal_polygonize.py added

Modified gdal_polygonize.py

comment:2 Changed 3 years ago by Flewellyn

I've attached a modified gdal_polygonize.py script, which adds the "-p"/"--float" option to run the process through GDALFPolygonize() instead of the integer-using GDALPolygonize. I can confirm that it works as expected.

comment:3 Changed 7 months ago by Even Rouault

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub?. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.