Looking at the QGIS API Documentation:

bool QgsFeature::hasGeometry    
    Returns true if the feature has an associated geometry.

Is invalid geometry different from a feature having no associated geometry? If so, is there a tool like .hasGeometry in PyQGIS that returns whether or not the geometry is valid?

1 Answer 1


Yes - they are two different concepts. A null geometry means "no geometry", vs an invalid geometry which means "there's a geometry, but it violates the simple features specification in some way"

To test geometry validity:

if f.geometry().isGeosValid():

Your Answer

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

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