[gdal-dev] Questions about polygonization

John Twilley mathuin at gmail.com
Tue Aug 19 19:19:08 PDT 2014


Hi Mike!

I get the same polygons you get -- what I don't understand is why I'm
getting those polygons instead of the ones that I expected.  Can you
explain why those polygons look like they should?

Jack.
--
mathuin at gmail dot com


On Tue, Aug 19, 2014 at 7:15 PM, Mike Toews <mwtoews at gmail.com> wrote:
> Hi Jack,
>
> I'm not sure if I understand the description of the shapes you see.
> Can you provide the WKT for them? I seem to get two polygons that look
> like they should:
>
> import numpy as np
> import rasterio.features
> from shapely.geometry import shape
> ar = np.ones((6, 5), 'B') * 11
> ar[2, 2] = 12
> gt = [0, 1, 0, 6, 0, -1]
> for (sh, v) in rasterio.features.shapes(ar, transform=gt):
>     print('%s: %s' % (v, shape(sh)))
>
> 11: POLYGON ((0 6, 0 0, 5 0, 5 6, 0 6), (2 4, 3 4, 3 3, 2 3, 2 4))
> 12: POLYGON ((2 4, 2 3, 3 3, 3 4, 2 4))
>
> -Mike


More information about the gdal-dev mailing list