In QGIS 2.18

I have two shapefile polygon layers, the actual case is quite complicated so I'm going to simplify it for the question. One is a layer of large polygons, say counties or states, and the other is a layer of smaller polygons , like individual properties or postcode districts. The polygons in the larger layer have an attribute representing a target, say the desired number of trees on each property. The smaller polygons layer has the actual number of trees each property has. I'd simply like to carry out some process which will highlight those properties/districts which are not meeting the target in their respective counties/states.

There are about 40 such targets I need to compare, so options that involve complicated transformations will not really solve the problem for me. What I need is some sort of expression I can select by which compares the value in one layer to another (I can already do this with the dbvalue() function), but only compare it to the value for the polygon it is contained by.


As it requires multiple steps of operations to compare the layers in desktop GIS.

The best solution I recommend for this case, import the two layers into PostGIS database and run the below SQL:

select  a.CountyName, b.PropertyID, a.TargetTrees, b.NumofTrees
from Layer1 a, Layer2 b where
ST_Contains(a.geom, b.geom) = true and b.NumOfTrees > a.TargetTrees;

Excuse me for any typo and syntax errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy