Opened 11 years ago

Last modified 6 years ago

#596 reopened defect

Invalid polygons give empty centroids

Reported by: sderle Owned by: strk
Priority: major Milestone: GEOS Fund Me
Component: Core Version: 3.3.3
Severity: Unassigned Keywords:
Cc:

Description

# select astext(way) from planet_osm_polygon where st_geometrytype(st_centroid(way)) <> 'ST_Point';

astext
---------------------------------------------------
 POLYGON((-73.042747 40.961426,-73.042571 40.961971,-73.042747
 40.961426,-73.0426927 40.9610055,-73.0426645 40.960956,-73.0426927
 40.9610055,-73.042747 40.961426))
 POLYGON((-73.042747 40.961426,-73.042571 40.961971,-73.042747
 40.961426,-73.0426927 40.9610055,-73.0426645 40.960956,-73.0426927
 40.9610055,-73.042747 40.961426))
 POLYGON((-65.912493 18.220862,-65.911621 18.220036,-65.911401
 18.219793,-65.910957 18.21916,-65.910925 18.219101,-65.910668
 18.218553,-65.910398 18.217805,-65.910024 18.216882,-65.90946
 18.215632,-65.909338 18.215362,-65.908986 18.21459,-65.908951
 18.214513,-65.908844 18.214279,-65.90866 18.213946,-65.908404
 18.213684,-65.908044 18.213497,-65.907776 18.213446,-65.907033
 18.213408,-65.906508 18.213338,-65.906074 18.213238,-65.905838
 18.213183,-65.906074 18.213238,-65.906508 18.213338,-65.907033
 18.213408,-65.907776 18.213446,-65.908044 18.213497,-65.908404
 18.213684,-65.90866 18.213946,-65.908844 18.214279,-65.908951
 18.214513,-65.908986 18.21459,-65.909338 18.215362,-65.90946
 18.215632,-65.910024 18.216882,-65.910398 18.217805,-65.910668
 18.218553,-65.910925 18.219101,-65.910957 18.21916,-65.911401
 18.219793,-65.911621 18.220036,-65.912493 18.220862))
(3 rows)

# select st_isvalid(way) from planet_osm_polygon where st_geometrytype(st_centroid(way)) <> 'ST_Point';                                

NOTICE:  Self-intersection at or near point -73.042747000000006 40.961426000000003
NOTICE:  Self-intersection at or near point -73.042747000000006 40.961426000000003
NOTICE:  Self-intersection at or near point -65.912492999999998 18.220862

st_isvalid 
------------
f
f
f
(3 rows)

# select astext(st_centroid(way)) from planet_osm_polygon where st_geometrytype(st_centroid(way)) <> 'ST_Point';

          astext          
--------------------------
 GEOMETRYCOLLECTION EMPTY
 GEOMETRYCOLLECTION EMPTY
 GEOMETRYCOLLECTION EMPTY
(3 rows)

# select postgis_version();
            postgis_version            
--------------------------------------- 
1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)

There are over 2,000 other geometries in this table for which ST_IsValid() fails, but which still produce centroids of type ST_Point.

System is Ubuntu 11.10 with stock GEOS 3.3.3 installed.

Change History (4)

comment:1 by strk, 11 years ago

Resolution: wontfix
Status: newclosed

Sorry but by contract you can't expect valid answers for invalid polygons.

comment:2 by sderle, 11 years ago

Resolution: wontfix
Status: closedreopened

Sorry but does PostGIS offer a way of cleaning up these polygons?

comment:3 by strk, 11 years ago

Milestone: 3.3.6GEOS Future

Not as easily as using single call. Some do using buffer with distance 0.

comment:4 by robe, 6 years ago

Milestone: GEOS FutureGEOS Fund Me

Milestone renamed

Note: See TracTickets for help on using tickets.