I want to get splitGeometry working example in qgis where i can find it. Official documentation have define here but this is not enough. Where i can get its working example in order to understand it and use in my project.

2 Answers 2


By using Official Documentation for 'splitGeometry' of QgsGeometry and shapefiles at next image:

enter image description here

I tried out my own code based in Maplus link:

mapcanvas = iface.mapCanvas()

layers = mapcanvas.layers()

feat_1 = layers[0].getFeatures().next()

feat_2 = layers[1].getFeatures().next()

if feat_1.geometry().intersects(feat_2.geometry()):
    success, splits, topo = feat_1.geometry().splitGeometry(feat_2.geometry().asPolygon()[0], True)

    if success == 0:

        print splits[0].exportToWkt()

        geom = QgsGeometry()

        print geom.fromPolyline(topo).exportToWkt()

First argument of 'splitGeometry' is a QgsPoint list, 'splits' is a geometry list and 'topo' is also a QgsPoint list. Results printed at Python Console of QGIS were:

enter image description here

So, I used QuickWKT plugin for visualizing these results:

enter image description here


Try GitHub search. Here is link: GitHub splitGeometry search

For some reason link is not working. Please just visit github page and write splitGeometry. Then click on Code on the left panel and choose python. There are 25 examples.

There are some examples how people use this method in python. It is very good way how to get info about using other methods in pyqgis because of small numbers of pyqgis examples.

Here are specific project using this method: Mapplus

geom_b = QgsGeometry(feat_b.geometry())
        if geom_b.intersects(geom_a):
            success, splits, topo = geom_a.splitGeometry(geom_b.asPolyline(), True) # split polygon by line
            if success == 0:
                     #if it success you can make other operations
  • what is this nothing found Sep 2, 2016 at 9:22
  • it should working now, sry for that. Is this OK now? I don't know why link didn't work.
    – Bulva
    Sep 2, 2016 at 9:24
  • If you have still problem with searching, just click on search again. It is working. There is 25 matches.
    – Bulva
    Sep 2, 2016 at 10:25
  • We could not perform this search Sep 2, 2016 at 11:10
  • You probably need account on github, did you try Mapplus link?
    – Bulva
    Sep 2, 2016 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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