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

Raymond Nijssen r.nijssen at terglobo.nl
Sun Jul 18 02:46:13 PDT 2021


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.


```
wkt = 'POLYGON((-1 0, 0 1, 1 0, 0 -1, -1 0))'

geom = QgsGeometry.fromWkt(wkt)

print(isinstance(geom, QgsGeometry)) # Outputs True
print(isinstance(geom, QgsAbstractGeometry)) # Outputs False

result = geom.isValid(0) # Outputs Error
print(result)
```

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

Is it supposed to work?

By the way, there's a geom.isGeosValid() that does work. But not a 
geom.isQgisValid()...

Thanks,
Raymond







-- 
Terglobo
Fahrenheitstraat 1
5223 BJ 's-Hertogenbosch
The Netherlands
+31 (0) 6 25 31 49 83


More information about the QGIS-Developer mailing list