[gdal-dev] gdal_polygonize and polygon edges

Jeff Lacoste jefflacostegdal at gmail.com
Tue Feb 19 11:28:31 PST 2013


Hi Frank,

Thanks for your quick response. Following the edges of the pixels seems a
perfect solution for non continuous grid (ex. land use, etc.) as
the boundary between the class is important to keep when constructing the
polygon. However for continuous grid (.ex elevations), the boundaries are
a bit not clear and not clear cut. When following the pixels edges, the
created polygons appear to have the stairs effect and are
less visually attractive.

I thought of a smoothing the polygons to not have *rough* edges using the
current gdal_polygonize by trying to not follow the pixels edges and use
instead of the
pixel centers. Basically do something similar to what contour generator
does by treating the raster values as continuous.

Thanks


On Tue, Feb 19, 2013 at 1:44 PM, Frank Warmerdam <warmerdam at pobox.com>wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130219/8b5742ee/attachment.html>


More information about the gdal-dev mailing list