Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been looking for the answer to this question for some time now, but can't seem to find it! My problem is straight forward: I have one layer It contains lots of features (only polygons), say countrys I want to merge some features together. Using python.

I know that I can select features with the mouse and hit the "Merge selected features"-button, but that is to slow. I can use python to select the features that i want, but how can i merge the selected features from python? (the features don't have a "common field" or something like that, what features are to be merged will be decided by in-data)

Help is greatly appreciated!

share|improve this question
up vote 3 down vote accepted

You can use QgsGeometry.combine( QgsGeometry ) for that.

Just loop over all your features and call

geom = geom.combine( currentFeature.geometry() )

with geom being a QgsGeometry

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.