2

I am working on development applications and need to generate some information. I have a buildings shapefile with the building footprints, as well as a parcel fabric shapefile.

What I want to do is create a new layer with geometry generator the will automatically give me dimension lines from the shortest distance of each face of the building footprint polygon which is situated within the parcel polygon to the face of each side of the parcel polygon. Basically, I want to generate how far the buildings polygons sides are from the corresponding lot line.

Any suggestions?

2
  • 1
    Welcome to GIS SE. As a new user, please take the Tour. The most common comments here are "What have you tried?" and "Where are you stuck?" If your Question doesn't address these it may attract closure votes. Commented Jul 15, 2025 at 11:39
  • Do you have attributes that connect the features that you consider related (building, parcel and lot?)? Commented Jul 21, 2025 at 6:46

2 Answers 2

5

Conceptual considerations

Firstly, working out the "corresponding" side of the parcel polygon, for each side of the building polygon, is not trivial, especially using Geometry Generator. Finding the closest parcel side is easy, but these two are often not the same thing.

See the example in the image below, which shows the distance from each building side to the closest parcel side. The building edge highlighted red is "facing" south, but it will always be closer to the western parcel edge, which is what you see (distance of 1.19 m).

It is much more complicated to match up "south" (building edge) with "south" (parcel edge), and get that distance (shown with a red ? in the image). Even the centre of building edges may not match up with the parcel edge you want.

enter image description here


Minimum distance to each parcel edge (not building edge)

A more straightforward approach might be to calculate the minimum distance from each parcel edge to the building (so, kind of the inverse of what you asked for, which was from each building edge to the parcel, which was covered in the previous section). By accounting for each parcel edge, the results may be more useful in determining minimum setback compliance.

The image below shows an example:

enter image description here

You will notice some buildings have more than 4 "minimum distance" lines coming out of them - that's because the parcel technically has more than 4 sides (this is real-world data where parcel digitisation includes little irregular segments...).

Expressions

To achieve the above, make sure both your buildings and parcels layers are in the same projected CRS, then use this expression in Geometry Generator on your building layer (with Geometry type set to LineString / MultiLineString) - replace 'parcel' in the expression with the name of your parcel layer (case-sensitive).

collect_geometries(
    array_foreach(
        geometries_to_array(
            overlay_within('parcel', -- set parcel layer name here
                            segments_to_lines(boundary($geometry)))[0]),
        shortest_line($geometry,@element)
    )
)

Under the geometry generator symbol, have a marker line symbol (on central point only), and use a font marker with the following expression under Character(s) - replace with ft as required:

round(length(geometry_n($geometry,@geometry_part_num)),2) || ' m'

The screenshot below shows what the setup should look like (geometry generator, simple line, and marker line with font marker) and shows where to use the expression above (yellow circle):

enter image description here

To fix the orientation of the font marker, follow the instructions under point 4 of this answer showing how to get polygon side dimensions.

You need to use a font marker to show distance, not labels, because while you can place a label in a geometry-generated position, the label engine has no way of accessing the properties (i.e., length) of each generated geometry (see discussion under the aforementioned answer).


Variations

Centre of parcel edge instead of vertex

You will notice that minimum distances above are drawn from a building vertex to a parcel vertex - that's because that will generally be the technically closest distance, geometrically.

You can get a prettier result by drawing the shortest line from the centre of each parcel side to the building by replacing shortest_line($geometry,@element) with shortest_line($geometry,centroid(@element)) in the geometry generator expression, which will look like this:

enter image description here

But this only looks nicer; it will no longer show the actual closest setback distance so please bear this in mind when assessing compliance.

Exclude small parcel segments

To avoid the "messy" look with irregularly drawn parcels, you can filter out parcel edges that are under a certain length, thus only getting building setbacks from "major" parcel edges. Use the expression below for geometry generator and set the minimum length as desired (here, only parcel edges 5 m and above are included).

collect_geometries(
    array_foreach(
        array_filter(
            geometries_to_array(
                overlay_within('parcel', -- set parcel layer name here
                                segments_to_lines(boundary($geometry)))[0]),
            length(@element) >= 5), -- set minimum parcel edge length here
        shortest_line($geometry,@element)
    )
)

Example with parcel edges 5 m and above filtered out (blue arrows):

enter image description here

3

You can use the QGIS hub (online) where some predifined styles are available also made with geometry generator: the "Polygons with measurements"-style does what you expect: https://hub.qgis.org/styles/21/

enter image description here

3
  • 1
    I don't think this is what OP was asking for, although it is a great tool. I believe they want to find the closest distance between edges of building polygons to the edges of the larger property/parcel polygon. This can be used to assess whether buildings meet minimum setback requirements from property boundaries. Commented Jul 17, 2025 at 1:13
  • yes..in fact, I missunderstood the question...thanks for clearing Commented Jul 17, 2025 at 17:31
  • This is exactly it! Any suggestions?? Commented Jul 18, 2025 at 2:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.