[QGIS-Developer] geom.isValid() does not work in python

Andrea Giudiceandrea andreaerdna at libero.it
Sun Jul 18 04:49:45 PDT 2021


Il 18/07/2021 11:46, Raymond Nijssen ha scritto:
> How can I run ths isValid() function on a geometry. I would think my 
> Polygon Geometry would inherit all functions from the 
> QgsAbstractGeometry base class, but it seems it doesn't.

> I get:
> AttributeError: 'QgsGeometry' object has no attribute 'isValid'

Hi Raymond,
the QGIS Python API documentation clarify that: "The actual geometry 
representation is stored as a QgsAbstractGeometry within the container, 
and can be accessed via the get() method"[1].

So, I think

geom.get().isValid()

will work without errors.

Best regards.

Andrea

[1] https://qgis.org/pyqgis/3.16/core/QgsGeometry.html#module-QgsGeometry


More information about the QGIS-Developer mailing list