[gdal-dev] gdal_polygonize and polygon edges
Daniel Morissette
dmorissette at mapgears.com
Tue Feb 19 12:35:01 PST 2013
Hi Jeff,
FYI we have been working on smoothing contours produced by gdal_contour,
and one of the issues that we encountered was having to deal with that
same stair effect (even with contours we get it in some cases). I don't
think that simplifying your polygons will be enough in your case, you
really need to do some smoothing, possibly combined with some level of
simplification (or not) depending on the scale at which you look at the
data (this is what we found anyway).
We found the following article describing a "Smoothing via Iterative
Averaging" technique:
http://www.ijcee.org/papers/501-P063.pdf
this technique is kind of simple but we found that it works better than
others on contours produced by sampling raster input like GDAL does. For
instance, bezier curves may sound like the obvious asnwer but they tend
to create overshoots in some situations which resulted in countours
crossing each other.
We ended up with an algorithm based on this SIA technique (plus a few
tweaks) which smooths the stair effects and tends to pass close to the
orginal points in most cases and most importantly does not produce
crossing contours.
We are going to share our code and results in the coming months (this
was done for MapServer), we are just not ready yet unfortunately.
Daniel
On 13-02-19 3:12 PM, Jeff Lacoste wrote:
> Yes visually attractive or smooth polygons is the goal. Thanks again Frank.
>
> Doing a web search about simplification algorithm i found one named
> '*Ramer-Douglas–Peucker'
> (*http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm).
> It appears that 'Geos'' library implement this algorithm. Is this
> algorithm exposed through OGR ?
>
> Could this algorithm help smoothing a polygon without necessary make the
> new nodes too far from the original one ? Or may be there
> are other *more* recommended algorithms ?
>
> If any one could suggest a simplification algorithm or had some
> experience with smoothing polygons, I appreciate their input.
>
> Thanks
>
> Jeff
>
>
>
>
> On Tue, Feb 19, 2013 at 2:42 PM, Frank Warmerdam <warmerdam at pobox.com
> <mailto:warmerdam at pobox.com>> wrote:
>
> On Tue, Feb 19, 2013 at 11:28 AM, Jeff Lacoste
> <jefflacostegdal at gmail.com <mailto:jefflacostegdal at gmail.com>> 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.
>
> Jeff,
>
> Ah, I see, you are looking for visually attractive polygons from
> continuous fields.
>
> I have wondered if it would be reasonable to produce a version of the
> contour generator that actually produces polygon regions. If we had
> that then applying appropriate simplification to the resulting very
> detailed edges should give something attractive and with reasonable
> information density. An appropriate simplification algorithm might do
> this in a reasonable way for the existing polygonize output but I
> don't know enough about the simplification algorithms to suggest one.
>
> I don't think aiming for pixel centers in gdal_polygonize would really
> solve the problem.
>
> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up | Frank Warmerdam,
> warmerdam at pobox.com <mailto: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
>
--
Daniel Morissette
http://www.mapgears.com/
Provider of Professional MapServer Support since 2000
More information about the gdal-dev
mailing list