I have two postgis layers:

  • The first layer contains the sidewalks of my town (polygons in blue).
  • The second one contains the pavements (roads) of my town (polygons in brown).

The map looks like this in QGIS with both layers activated:

enter image description here

Ok, now I have to obtain a layer with the curbs (lines) in the town starting from these two layers. The new layer must be composed of linestrings. Each element in this new layer should be a linestring where every of the greometries of the two layers intersect.

In the following snapshot I manually painted the geometries that should be created in this particual area:

enter image description here

Sorry about my bad pulse. I hope it helps to understand me better.

Ok, if I just add the layers to QGIS, for example, and intersect one layer with another I get the following layer:

enter image description here

The new green layer is the obtained curbs layer. I have two snags with this layer:

  • It is composed of polygons
  • Not all the curvs are drawn.

With this last evidence I discover that the sidewalks and roads layers were not precisely delineated one next to the other, so I need some kind of tolerance in the operation to get the layer I am looking for. As I told before it should be a linestring layer.

I don't mind if the query is directly done in postgis or using QGIS or other software's tools, I just can't figure out right now how to solve this.

1 Answer 1


In PostGIS you can use ST_Buffer to add a little margin to one of the polygon layers, then use ST_Intersection to get the curbs polygon. Now the ST_StraightSkeleton may give you what you want (haven't actually tested but it should work).

As noted below skeletonize produces wrong result. The better way should be to do ST_DumpRings on the roads polygon and get ST_Intersection of rings and the curb polygon.

  • Hi @Jakub Kania thanks for your post. If I use straight skeleton I obtain a multilinestring layer with some kind of perpendicular lines that i don't want.. Please see next snapshot: imgur.com/AhXx5xs
    – Egidi
    Commented Sep 3, 2015 at 9:26
  • @Egidi Yes, skeletonize was probably an overkill. I edited with a suggestion but I don't really have time right now to prepare a proper answer, I'll try to get back to it. Commented Sep 7, 2015 at 15:26

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.