I have esri ascii grid raster files like
ncols 4
nrows 3
xllcorner 0
yllcorner 0
cellsize 1
nodata_value -999
1 2 3 4
4 21 3 3
3 2 31 1
How can I convert this into vectorized (WKT) format when simplifying / reducing polygons via a binning of the values i.e. neighbors within a range of 0...10...20...30 should be put into the same polygon.
Naively this translates to
1.0;POLYGON ((1 3, 0 3, 0 2, 1 2, 1 3))
4.0;POLYGON ((1 1, 1 2, 0 2, 0 1, 1 1))
3.0;POLYGON ((0 1, 0 0, 1 0, 1 1, 0 1))
2.0;POLYGON ((1 2, 2 2, 2 3, 1 3, 1 2))
21.0;POLYGON ((1 1, 2 1, 2 2, 1 2, 1 1))
2.0;POLYGON ((1 1, 1 0, 2 0, 2 1, 1 1))
3.0;POLYGON ((3 1, 4 1, 4 2, 3 2, 3 3, 2 3, 2 1, 3 1))
31.0;POLYGON ((3 1, 2 1, 2 0, 3 0, 3 1))
4.0;POLYGON ((3 2, 4 2, 4 3, 3 3, 3 2))
1.0;POLYGON ((4 0, 4 1, 3 1, 3 0, 4 0))
I can aggregate/bin the numbers into a range from 0...100 with steps of 10 and group-by aggregate (ST_CONCAT/ST_UNION) the geometries, but this is not what I want to achieve. I.e. When creating the polygons I would rather only want to create them in aggregated fashion. So for the value range, it should be already in the binned range, and for the polygons they should be considered neighbors if a) next to each other b) binning interval is the same.
Answer
I think reclassification is the right tool. Gdal supports this and Getools PolygonExtractionProcess via classificationRanges as well.
Here I declared my bins.
No comments:
Post a Comment