I have a polygon layer with every cities in my region. One of the field of this layer is the population of the city.
I also have a line layer which represents some bus route
I would like to automaticaly calculate the population concerned by the bus route (which means the sum of population of the polygon intersect by each bus line).
First of all how to calculate this in a new field on the line layer?
Second how to get this result to be update if the route change?
Answer
First of all how to calculate this in a new field on the line layer?
Install the RefFunctions plugin.
Use the Field Calculator to add a field to the bus route layer with this expression (substitute your actual field and layer names):
intersecting_geom_sum('city_polygons','population')
Second how to get this result to be update if the route change?
Make it a virtual field if you only need the values in the current project.
If you need the values saved as a permanent part of the layer's attributes, make it a regular field with a default field value. Check the box for "Apply default value on update." Note that the field won't update if the layer isn't in edit mode; you may also need to make some sort of change to trigger the update.
No comments:
Post a Comment