2

I am trying to create polygons between contour polylines within a defined area (for which i have both polygon and polyline shps) but I seem to be thwarted at every turn. Using QGIS 2.14, I am sure it is an easy enough operation but the actual process eludes me. I have performed the task easy enough in ArcMap 10.x, but need to reproduce in QGIS/GRASS/SAGA.

As far as I know, the Polygonize tool from the Processing toolbox is the one that I'm after. Unfortunately, it spits out the same error:

'NoneType' object has no attribute 'isMultipart'

2
  • 1
    isMultiPart() is a method of class QgsFeature. This error means that at least one feature has geometry() None. It might be a degenerated contour line with length 0, or some other error concerning geometry.
    – Detlev
    Commented Mar 23, 2016 at 22:07
  • Thanks, that solved it. A zero-length polyline had crept in during one of the merges.
    – mastorey
    Commented Mar 23, 2016 at 22:35

1 Answer 1

2

isMultiPart() is a method of class QgsFeature. The error 'NoneType' object has no attribute 'isMultipart' means that at least one feature has geometry() of None. It might be a degenerated contour line with length 0, or some other error concerning geometry.

If you have problems using a provided tool, then first check geometry, eg delete polyline having length equal 0, polygon having area equal 0, or check their topology. This problems may or may not raise errors in tools, depending on which error handling the developer has taken into consideration.

In case you have written python code that raises this error, test the QgsGeometry object before using its methods or process the underlying geometry store:

geom = geometry()
if geom:
    if not geom.isEmpty():
        # do something useful

Or more in-depth checking:

geom = geometry()
if geom:
    err = geom.validateGeometry()
    if not err:
        # do something useful
    else:
        print '%d geometry errors detected' % len(err)

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.