Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_containing_feature(value1, feature, parent):
- cont_feature = None
- cont_layer = QgsMapLayerRegistry.instance().mapLayersByName(value1)[0]
- crsSrc = QgsCoordinateReferenceSystem(4326) # WGS 84
- crsDest = cont_layer.crs()
- xform = QgsCoordinateTransform(crsSrc, crsDest)
- curr_geom = feature.geometry()
- curr_geom2 = xform.transform(curr_geom.asPoint())
- features = cont_layer.getFeatures()
- for feat in features:
- if feat.geometry().contains(curr_geom2):
- cont_feature = feat
- break
- return cont_feature
Add Comment
Please, Sign In to add comment