Last active
August 13, 2023 13:19
-
-
Save timlinux/9179a2fc619a26c3ad4a to your computer and use it in GitHub Desktop.
A QGIS Python snippet to select multipart features in the active layer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find all multipart features in the active layer | |
l = iface.activeLayer() | |
iter = l.getFeatures() | |
geoms = [] | |
for feature in iter: | |
geom = feature.geometry() | |
if geom.isMultipart(): | |
l.select(feature.id()) | |
geoms.append(geom) | |
print 'There are %i multipart features in this layer' % len(geoms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use QGIS 3.22, but this code selects all features in an active layer, not the multipart feature. Do you update it already? If not, I may create an alternative code after this.