I am using the python code found in Programmatically finding polygons which are >90% overlapped by another vector polygon layer using QGIS?.
I get the following message
error: NameError: name 'area1' is not defined
Here is the concerned part of the code:
for i, feat1 in enumerate(feats_lyr1):
for j, feat2 in enumerate(feats_lyr2):
if feat1.geometry().intersects(feat2.geometry()):
area1 = feat1.geometry().intersection(feat2.geometry()).area()
area2 = feat1.geometry().area()
crit =area1/area2
if crit > 0.9:
selected_feats.append(feat1)
After checking lots of things (geometry, CRS, ..), the only thing I see is that i have null area for couple of polygons.
- Is that possible that small areas, close to zero, are considered to be zero if considered as integer number?
- how to ensure the use of decimal number?
crit =area1/area2 if crit > 0.9: selected_feats.append(feat1)inside secondfor– Fran Raga Dec 19 '17 at 19:49