1

enter image description hereVery beginner in QGIS, I want to do split Features using PyQGIS. I have written this code so far it giving me polygon of the layer but i don't know how to split it through coding?

layer = iface.activeLayer() //get active layer
for f in layer.getFeatures():
  geom = f.geometry()
  print geom.asPolygon()//get polygon

As picture suggested, a big polygon contains small polygon i want to split all small polygons in the same layer.

  • 1
    I think you need to describe your problem in greater depth. What do you want to split? How do you want to split them? Maybe a drawing or two to illustrate what you want to do? – Chau Sep 1 '16 at 8:32
  • 1
    I still quite doesn't understand what you're trying to do. In the image, do you want to use the small polygon to cut a hole in the large polygon? Do you have a multi-part geometry that you want to make into single parts? – Chau Sep 1 '16 at 10:25
  • yes i want to split/cut the polygon from the large polygon. did u ever use split feature in qgis? i want to automate it through coding – Muhammad Faizan Khan Sep 1 '16 at 10:54
  • split feature will help to split geometries.it clear to you now? – Muhammad Faizan Khan Sep 1 '16 at 10:55
  • When you start coding things in python instead of using the user interface, depending on what you want, you might be able to utilize other algorithms and thus create some better code. – Chau Sep 1 '16 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.