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.


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.

enter image description here

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.


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.

  • Maybe, with the new postgis topology module, the street boundary, could be grouped together to form this polygon( closed area ).
    – cavila
    Dec 14, 2013 at 17:14
  • How would you propose to get the block? The street is (conceptually) a linestring, whereas each block is a polygon. How would you locate a single urban block given a linestring, in the presence of easements, parks, nature reserves, battleaxe blocks (e.g. anewhouse.com.au/2012/07/battleaxe-block), blocks where there is a river / creek / ridgeline between the streets, etc?
    – BradHards
    Dec 14, 2013 at 23:36
  • Thanks @Cavila, I was looking for examples, and find some like this one, that somthing that I need, but: all start with polygons, not with "tesselation segments" (see my generalization of the problem). My input is a set of segments. Dec 15, 2013 at 11:45
  • @BradHards, thanks for your review (!), I edited to show the focus of my problem. Yes there are a lot of exceptions like a battleaxe block; and yes, I need to add river-segments, railways-segments, etc. for a "complete tesselation". I need only the "first approximation" of blocks, not a complete and automated construction of them. Dec 15, 2013 at 11:51
  • I guess he is willing to get the block or sector based on street boundary. Not a single urban lot for a single property. One solution could be resample a walker that plots a symbol at a start point and starts walking turning to his right until he comes back to the start place where he plotted the symbol. So you will get a polygon or closed boundary.
    – cavila
    Dec 17, 2013 at 11:59

2 Answers 2


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.


The new function ST_Split can be used as alternative solution, since Postgis v2.5.0:

  1. define a "city polygon", citypol, it could be the whole city or a fragment of it.

  2. define the mergedlines of streets. Can be the same (SELECT ST_Union(geom) as geom FROM lines) mergedlines, as in the @dbaston solution.

  3. ST_Split( citypol, mergedlines )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.