[gdal-dev] Questions about polygonization

John Twilley mathuin at gmail.com
Tue Aug 19 18:42:13 PDT 2014


I am trying to use GDAL's polygonize algorithms to help me identify
regions in landcover data.  I made a trivial example, but I am having
trouble understanding the results that I get, nor can I determine how
to get the results I want.

Given the following raster:

11 11 11 11 11
11 11 11 11 11
11 11 12 11 11
11 11 11 11 11
11 11 11 11 11
11 11 11 11 11

If I were to polygonize this raster, I would expect two polygons:  one
which contains the single point 12, and another with an outer ring was
the perimeter of the raster and an inner ring circling the single
point 12.  I would also expect that the first polygon would contain
the single point 12 and that the second polygon would contain all the
points 11.

Instead, what I got was a polygon starting from the single point 12
and extending down and to the right one pixel, and another polygon
with an outer ring that went off the down and right edges and an inner
ring equal to the first polygon's outer ring.  The first polygon
doesn't actually contain any points and the second one doesn't contain
any points on either ring but does contain all the other points.

What do I need to do to get the results I am expecting?

Jack.
--
mathuin at gmail dot com


More information about the gdal-dev mailing list