[gdal-dev] gdal_polygonize and polygon edges

Jeff Lacoste jefflacostegdal at gmail.com
Wed Feb 20 07:08:32 PST 2013


Thanks every one who responded to my post.

Jeff: it appears that your approach involve smoothing the original grid
before generating contours (or polygons from it). Right ? It would be nice
if I could have the smoothing either as an after process operation
or ideally as an option within the polygons generation process itself.

Daniel: Using 'SIA' technique sounds promising. Does it apply to polygons
as well ? or just polylines ? I would be interested to test (and later use
if applicable) your approach.
If would like an extra tester, please let me know.

Graeme: Is your tracing technique a new algorithm different from
GDAL_Polygonize ? Is there a C/C++ code I can build or may be an .exe
utility I could use to try out ?

p.s: i did not have a chance to try out '*'Ramer-Douglas–Peucker' yet.*

Thanks
Jeff Lacoste


On Tue, Feb 19, 2013 at 5:39 PM, Brian Case <rush at winkey.org> wrote:

> a few years ago someone had posted some perl code for making polys from
> the contour output.
>
> the idea was to sort the lines into an m-way tree by contains with the
> root node being the extent of the data then each node would be outer
> ring and a copy of the children being the inner rings
>
> i have done this myself and it works
>
> Brian
>
>
> On Tue, 2013-02-19 at 14:28 -0500, Jeff Lacoste wrote:
> > 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
> >
> >
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
> --
> Brian Case
> KF7WPK
> rush at winkey.org
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130220/34cca483/attachment-0001.html>


More information about the gdal-dev mailing list