Hi,


I’m running qgis 3.16 on w10.



I have two vector layers with multiple entities :

·         One with each town borders (? I’m note sure if this is the right
word) I mean the area for each zip code. (TOWN_LAYER) (polygon vector)

·         The second with cropfields and meadows (polygon vector)
(FIELD_LAYER)



I want the total area of cropfield and Meadows in each Town from the first
layer. (Exemple : one town have 31 fields/meadows -> total town area is
55km² (i have that info) and cropfield/meadows area is 26km² (i need that
one for each town)



First i tried something like :

·
Sum(area(intersection($geometry,geometry(‘FIELD_LAYER_ID’))),group_by
:=FIELD WITH SAME VALUE EVERYWHERE)



But it is not a valid expression (geometry(‘FIELD_LAYER_ID’) don’t work)



Some meadows span over several town. Some juste inside one.

I’ve « cut » the FIELD_LAYER with the TOWN_LAYER



My first vector layer as a field specific and i’m looking for the formula
that would give me the right answer.



I’ve tried :



·         aggregate (layer :=’FIELD_LAYER_ID’, aggregate :=’sum’,expression
:=$area, filter := intersects($geometry, geometry(@parent)))



It doesn’t work because the borders are overlapping : each fields just
touching the borders even if they belong to another town are included.



« Contains » instead of « intersects » doesn’t work either because some
borders of the field are overlapping and those are not included.



Exemple with « count » instead of « sum »



A town have 31 fields spanning over 26km² : Intersects give me a total count
of 38 and 48km² and contains give me 12 and 4,7 km² because of borders
overlap.



I think the solution is with intersection, but i can’t reach a valid
expression.



Another solution may be splitting the FIELD_LAYER in as much layer as town
(I did that) and batch process for each layer :

·         sum($area,group_by := FIELD WITH SAME VALUE EVERYWHERE)



then get the result in the TOWN_LAYER.



But i don’t know how to batch process it and get the result in the first
layer.



And for informations I’m talking hundreds of towns and thousands of
fields/meadows entities so one by one calculation is not possible.



I hope I make sense and that someone know how to deal with that.



Thanks,



Edouard BOURGINE

Ingénieur Environnement



Tél/Fax : 03.83.22.69.09

Port : 06.63.12.99.63



ACOSOL

26 rue de l’Ornain

54520 LAXOU





--
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to