Theoretically is possible to obtain the polygons of city blocks (urban blocks) from streets, when streets are represented by street axis (LineStrings).
The urban blocks are bounded by streets, so the street segments can be used to form a polygon which contains only one block inside... See illustrations.
There are an (SQL) PostGIS 2.X script to do this? A plugin software?
PS: approximate city block geometries are enough.
Illustrating
Starting the process from a "mesh of connected line segments", it can be: 1) obtain associated polygons; 2) isolate polygons by negative buffer and buffer subtraction of the lines.
Example: the polygon 262 (representing a city block) was originated by the segments 2496, 2494, 2369, 1513, ... And the neighbor polygon 263 can use some common segments, but next (by negative st_buffer or another operation) will be really isolated polygons, so, low precision is enough.
(EDIT)
I think we can translate this specific problem in a more generic one: the set of street segments can be viewed as a kind of tessellation, that is, the segments separe the plane into contiguous regions – the urban blocks are lying in the interior of these regions. Each segment is a side of two regions.
The main problem is to transform the "set of segments of the tessellation" into independent polygons.
Answer
The ST_Polygonize
aggregate in PostGIS will return a geometry_dump
containing all possible polygons formed by a set of lines. I'm assuming the block IDs shown in your example are not related to the IDs of input linework. If this is the case, you can get your polygons and IDs with:
SELECT (st_dump).path[1] as poly_id, (st_dump).geom FROM
(SELECT ST_Dump(ST_Polygonize(geom)) FROM
(SELECT ST_Union(geom) as geom FROM lines) mergedlines) polys
The slow part here is the ST_Union
. It seems like this should work without that call, as long as the input lines are properly noded, but I haven't been successful doing so.
A negative buffer won't give the exact results shown in your example, because the dead-end streets will be ignored by the polygonization process. But you can take a positive buffer of the original linework, and use ST_Difference
to remove that area from the block polygons.
No comments:
Post a Comment