8

I'm new to working with GIS data and QGIS. I'm trying to find an efficient way to measure/calculate the width of streets in a city. I have two datasets: buildings (polygons) and streets (lines).

I'm interested in the average distance from the facade to facade for each side of a block (from 1 crossing to the next).

Is there a way to calculate the distances between the polygons (distance A in the picture) or between the polygons and the lines (distance B)?

example

nodes

The nodes of the buildings are manly at the corner points (with some exceptions, as seen in the picture). The lines of the streets end at every crossroad. Very few of the lines have additional nodes (e. g. at the bottom left corner of the picture).

4
  • 1
    Basically the answer is "yes". But without further information on which distances exactly you need, we can't answer your question thoroughly. E.g., in how many distances per feature are you interested? Do they have to be perpendicular? Are you taking into account, that not all buildings are placed at the edge to the streets (like, there might be small gardens etc). Are you interested in the smallest, the largest, or an average width? For the whole street, or for each block? What further processing are you intending?
    – Erik
    Jan 24, 2020 at 11:14
  • 1
    I will update my post. Essentially I'm interested in the average width for each side of a block (so from 1 crossing to the next). For my purpose it's not that important if the building is placed at the edge of the street. It's about the distance from facade to facade.
    – rababa
    Jan 24, 2020 at 11:49
  • Can you show (in the picture) the nodes of the buildings and the lines (toggle editing e.g.)? Do the lines end at every crossroad or do they overlap?
    – Stefan
    Jan 24, 2020 at 12:55
  • i added a picture with the nodes of the buildings and the streets in the post.
    – rababa
    Jan 26, 2020 at 8:50

1 Answer 1

6

Since QGIS version 3.16, you have new overlay expressions you can use for this. For older versions see the refFunctions Plugin.

I have a polygon layer with buildings (orange) and a street layer (blue), both from OpenStreetMap. You can create the shortest line from each building to the street-layer, thus to the nearest street feature, using this expression:

shortest_line ( 
    collect_geometries ( 
        overlay_nearest ( 
            'streets', 
            $geometry
        )
    ),
    $geometry
)

In the following screenshot, I demonstrated it using geometry generator to create a red line. However, you should use Menu Processing / Toolbox / Geometry by expression and paste the expression there to create a new line layer because you want to measure the length of the red lines. You can see that the length appears on the screenshot: that's because I created a line layer as described and used this to create labels.

Be aware of cases like the one at the bottom left with a buiding in the rear - the expression creates you a line, but since you have buildings that are nearer to the street, this one should be rejected.

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.