# [postgis-users] How to create block polygons from street network?

Picavet Vincent Vincent.Picavet at mediapost.fr
Fri Apr 24 01:23:08 PDT 2009

```Hello,

> Objet : [postgis-users] How to create block polygons from
> street network?
>
> Hi all,
>
> Here is an interesting problem that I could use some
> suggestions and/or sample code for. I have a street network
> where all the street segments are noded at intersections.
> What I need to extract is all the blocks in the coverage. A
> "block" is the smallest polygon bounded by segments that does
> not have any segment crossing it. It could have a cul-de-sac
> protruding into its interior as long as it does not divide
> the polygon in two.

We do exactly that in our process, based on a topological graph network
generated from Teleatlas data.
I can't give you the code as I'm not allowed to, but here is the general
method we use.

* First build a planar network with edges and nodes and topological
information (from/to nodes for edges).
* Introduce the concepte of <frontage> of an edge, which represent one
side of the edge and is attached (linked) to one of its extremal nodes
(choose left or right side and start or end attachment as a convention).
* given its edge geometry, compute the absolute angle, then the order of
a frontage on its attached node (clockwise or ccw as you wish).
* with this information, for each frontage you can compute a <next
frontage> and <previous frontage> information by turning first right (or
left) at every node.
* Now following the <next frontage> links, you can compute closed sets
of frontages until returning to the first one, this sets defining blocks
as you mean it.
* with edges geometry of frontages sets you can now build a polygon

This is a fairly complicated process, but has given very good results in
our case, and let you do navigation as well with these informations.

Do not hesitate if you need further information, as far as I'm allowed
to give it to you :)
Good lu
ck
Vincent

```