I want to compute surface areas of a large CityGML data set. However, I ran into some issues, which I could not resolve or fully understand.
The error message is the following:
Polygon is invalid : points don't lie in the same plane
Minimal examples:
SELECT st_3darea( ST_SetSrid(ST_GeometryFromText( 'POLYGON Z ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0))' ),4258))
/*<- This works fine */SELECT st_3darea( ST_SetSrid(ST_GeometryFromText( 'POLYGON Z ((0 0 0, 0 1
1
, 1 1 0, 1 0 0, 0 0 0))' ),4258))
/*<- This does not work: Error Polygon is invalid : points don't lie in the same plane */SELECT st_3darea( ST_SetSrid(ST_GeometryFromText( 'POLYGON Z ((0 0 0, 0 1
1
, 1 1
1
, 1 0 0, 0 0 0))' ),4258))
/*<- This works fine again */SELECT st_3darea( ST_SetSrid(ST_GeometryFromText( 'POLYGON Z ((0 0 0, 0 1 1, 1 0 0, 0 0 0))' ),4258))
/*<- This works fine, removed one point */
From my understanding in 2), the function is not able to transform the coordinates into a flat plane to proceed with its calculations. Somehow, I am not sure if it is a bug or a feature (is the polygons in 2) invalid, why?)
As answered by@geozelot, its not a bug, but PostGIS does not support curved geometries.
My idea for a solution:
Is there a generic workflow/function to split polygons (e.g. 2)) in a form like in 4) triangles and then add the sums of the areas?
I would need it automated for the CityGML data set, which I do not know how to do e.g. non-automated
SELECT st_3darea( ST_SetSrid(ST_GeometryFromText( 'POLYGON Z ((0 0 0, 0 1 1, 1 0 0, 0 0 0))' ),4258))
+
SELECT st_3darea( ST_SetSrid(ST_GeometryFromText( 'POLYGON Z ((0 1 1, 1 1 1, 1 0 0, 0 1 1))' ),4258))