Skip to content

Instantly share code, notes, and snippets.

@dimasmaulana99
Forked from timlinux/find_multipart.py
Created August 13, 2023 13:19
Show Gist options
  • Save dimasmaulana99/93f28c1056337822a11c823633e272a6 to your computer and use it in GitHub Desktop.
Save dimasmaulana99/93f28c1056337822a11c823633e272a6 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
layer = iface.activeLayer()
# Clear the selection first
layer.removeSelection()
# Iterate through features and select the multipart ones
for feature in layer.getFeatures():
geom = feature.geometry()
if geom.isMultipart():
layer.selectByIds([feature.id()])
print('Multipart features selected:', layer.selectedFeatureCount())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment