Skip to content

Instantly share code, notes, and snippets.

@timlinux
Last active August 13, 2023 13:19
Show Gist options
  • Save timlinux/9179a2fc619a26c3ad4a to your computer and use it in GitHub Desktop.
Save timlinux/9179a2fc619a26c3ad4a to your computer and use it in GitHub Desktop.
A QGIS Python snippet to select multipart features in the active layer
# 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)
@dimasmaulana99
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment