The image below is a representation of a digitised urban area derived from Google Satellite and OSM. The black lines between nodes are street segments and the irregular polygons are households.

enter image description here

I want to calculate the number of households along a street segment - the initial approach was to specify a buffer around each line segment in QGIS, and then use the 'Join attributes by location' to derive counts of households that fall within the buffer zone. However, I realise this is not a robust approach.

Is there an appropriate way of performing this calculation?

  • 1
    no matter what approach, without any additional rule/filter/information I'd say you'd end up with (without knowing your use case I dare say) rather meaningless results; which building to count at intersections or what to do with staggered/offset buildings? e.g. a basic, unique (but not necessary correct) selection could be to find the closest road segment to each building polygon (or polygon centroid, or...)? ideally, you'd have additional geometries representing entrances or 'front' or sth.
    – geozelot
    Commented May 21, 2018 at 12:34
  • @ThingumaBob, unfortunately, we do not have any other additional geometries which specify the front entrance of a household. In hindsight, this would have made sense to collect during the survey as such information would have made linking the household data to the street segments easier. Nevertheless, I try linking them to the nearest line segment as you've suggested. Thank you for your comment. Commented May 21, 2018 at 12:57

1 Answer 1


With each limitation regarding correctness said by ThingumaBob there is the possibility to search the line segment closest to the building geometries.

The QGIS own function distance matrix works for point-to-point only. But you can use the v.distance function from the grass processing tools (https://grass.osgeo.org/grass75/manuals/v.distance.html). Or as an alternative ST_Distance when creating a SpatiaLite DB and use the function via the DB-Manager.

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.