[gdal-dev] Questions about polygonization

Mike Toews mwtoews at gmail.com
Tue Aug 19 19:15:12 PDT 2014


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