TransWikia.com

QGIS - Counting vertexes in radius from each feature in line layer

Geographic Information Systems Asked by Klaus_Asbjorn on February 1, 2021

I am looking to measure the impact of urban green on pedestrian route choice, and in that connection I want to create a new field within a line layer that counts how many trees exist in a radius of 10 meters from the center of each feature in the line layer. (could also be within the radius of 10 meters from the two extremes of the line, doesn’t matter so much).

I am working in QGIS 3.4.13-Madeira.

Am at a total loss as to how to do this, and can’t seem to find any articles that might point me in the right direction.

urban green

(the points are trees)

One Answer

Assuming your roads layer has no respective field yet:

  • mark the layer and open the Field Calculator
    • toggle Create a new field
    • choose an Output field name
    • select Output field type: Whole number (integer)
    • paste this expression:
      aggregate( '<tree_layer_name>', 'count', '', distance( geometry( @parent ), $geometry ) <= <dist> )

      with <tree_layer_name> replaced with the actual name of the tree layer, and <dist> replaced with the search radius around the line feature

      Note:
      The <dist> value will be treated as units of CRS, meaning that, if your layers are referenced in EPSG:4326 (or any geographic reference), these will be degrees. For it to be treated as meters, make sure your layers are projected in a suitable metric projection!

Answered by geozelot on February 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP