[gdal-dev] gdal_polygonize and polygon edges

Brian Case rush at winkey.org
Tue Feb 19 14:39:16 PST 2013


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




More information about the gdal-dev mailing list