<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi Frank,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Thanks for your quick response. Following the edges of the pixels seems a perfect solution for non continuous grid (ex. land use, etc.) as</div>
<div style="font-family:arial,sans-serif;font-size:13px">the boundary between the class is important to keep when constructing the polygon. However for continuous grid (.ex elevations), the boundaries are</div><div style="font-family:arial,sans-serif;font-size:13px">
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.</div><div style="font-family:arial,sans-serif;font-size:13px"><br>
</div><div style="font-family:arial,sans-serif;font-size:13px">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</div>
<div style="font-family:arial,sans-serif;font-size:13px">pixel centers. Basically do something similar to what contour generator does by treating the raster values as continuous.</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Thanks</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 19, 2013 at 1:44 PM, Frank Warmerdam <span dir="ltr"><<a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Feb 19, 2013 at 10:29 AM, Jeff Lacoste<br>
<<a href="mailto:jefflacostegdal@gmail.com">jefflacostegdal@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I'm using gdal_polygonize.py to create polygon from a grid and the output<br>
> polygons seems to follow the edges<br>
> of the grid pixels. I was wondering if there is any way to change/edit the<br>
> code to instead of following the edges<br>
> of the pixels, use the center of the pixels as the nodes of the created<br>
> polygons ?<br>
><br>
> So instead of a polygon following the edges of the pixels, it will instead<br>
> be passing through the center of the connected<br>
> pixels... This is to avoid having a scale effect of following the pixels<br>
> edges.<br>
<br>
</div></div>Jeff,<br>
<br>
With the current algorithm, this is not really possible.<br>
<br>
I am also not clear what it would mean to go from pixel center to<br>
pixel center. The algorithm attempts to identify the borders between<br>
regions of different pixel values and turn them into polygons. What<br>
does it mean to make a polygon boundary that goes through the center<br>
of a pixel with a particular value?<br>
<br>
Another algorithm you might want to keep in mind is the contour<br>
generator. It treats the the raster values as a continuous field, and<br>
builds edges based on linear interpolation between pixel centers.<br>
This gives a result that could pass through a pixel center if it<br>
happens to be an exact contour level.<br>
<br>
Best regards,<br>
<span class="HOEnZb"><font color="#888888">--<br>
---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush | Geospatial Software Developer<br>
</font></span></blockquote></div><br></div>