[gdal-dev] gdal_polygonize and polygon edges

Frank Warmerdam warmerdam at pobox.com
Tue Feb 19 10:44:49 PST 2013


On Tue, Feb 19, 2013 at 10:29 AM, Jeff Lacoste
<jefflacostegdal at gmail.com> wrote:
> Hi,
>
> I'm using gdal_polygonize.py to create polygon from a grid and the output
> polygons seems to follow the edges
> of the grid pixels. I was wondering if there is any way to change/edit the
> code to instead of following the edges
> of the pixels, use the center of the pixels as the nodes of the created
> polygons ?
>
> So instead of a polygon following the edges of the pixels, it will instead
> be passing through the center of the connected
> pixels... This is to avoid having a scale effect of following the pixels
> edges.

Jeff,

With the current algorithm, this is not really possible.

I am also not clear what it would mean to go from pixel center to
pixel center.  The algorithm attempts to identify the borders between
regions of different pixel values and turn them into polygons.  What
does it mean to make a polygon boundary that goes through the center
of a pixel with a particular value?

Another algorithm you might want to keep in mind is the contour
generator.  It treats the the raster values as a continuous field, and
builds edges based on linear interpolation between pixel centers.
This gives a result that could pass through a pixel center if it
happens to be an exact contour level.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Software Developer


More information about the gdal-dev mailing list