I want to get the perimeter of each polygon (building) I have. Some polygons are adjacent, thus sharing a side. Shared sides should be excluded from the calculation for each polygon. In simpler words: I need to get the exposition perimeter (and then the surface) of each building. One workaround I came up with is:

  1. get the lines from the polygon and assign to these line features the polygon ID. No matter which ID gets assigned to the shared sides.
  2. create a dissolved layer of these polygons so that adjacent polygons are merged into one, then get a negative buffer. The buffering should be as tight as possible (smaller than the smallest polygon).
  3. use this negative buffer to exclude the intersected lines, which should only be the shared sides.

Is there a more straightforward and possibly safer approach to get perimeters without shared sides?

  • 1
    I suggest you to use topology data; topology stores the boundaries as arcs, as well as which polygons share these arcs, so you are looking for polygons that have an arc shared with no other polygon (or the "outer" polygon), you may do that in postgis or with topojson gis.stackexchange.com/questions/447724/…
    – Elio Diaz
    Commented Dec 15, 2023 at 16:53

2 Answers 2


Use this expression to calculate the perimeter without shared sides:

     intersection (
             buffer (
                 collect_geometries (
                         overlay_touches (@layer, $geometry),

Remark: make sure you use a local CRS that is suitable for measurements, e.g. local UTM zone or a national grid.

The expression (including a round() function) used to calculate the outer perimeter - for visualization purpose, the blue lines show the distance measured for each polygon; the polygon in the red oval shows the calculated vs. measured value to demonstrate that the expression returns the desired result:

enter image description here


This seems to do the trick:

  1. "Dissolve" the building layer
  2. Convert the dissolved layer to lines using "Polygons to lines"
  3. Run the "Intersection" tool between the original buildings and the lines


enter image description here


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.