[postgis-users] TopologyException: geom is invalid

Joseph Spenner joseph85750 at yahoo.com
Wed Feb 25 09:14:25 PST 2015


Hello,I have a perl script which uses a geoJSON as input, and queries a table to see if any polygons exist in the table with any points in common.  If any matches are found, they are returned as geoJSON.  It's been working great, but yesterday I got an error.  Here's my query:
select ST_Asgeojson( geom ) from dynamic.polys where ST_Intersects(ST_GeomFromGeoJSON('$jsonPoly'), geom)=TRUE and ST_Area(ST_Intersection(ST_GeomFromGeoJSON('$jsonPoly')::geography, geom::geography))>500
With my current issue, the $jsonPoly is the state of Californina.   The select from dynamic.polys should return any polys in my database which have any points in common with California.

However, yesterday I had a query which resulted in the following error:
DBD::Pg::st execute failed: ERROR:  Error performing intersection: TopologyException: Input geom 1 is invalid: Self-intersection at or near point -381688.06935935974 -1206669.4272876547 at -381688.06935935974 -1206669.4272876547 at ./test.pl line 151.
DBD::Pg::st execute failed: ERROR:  Error performing intersection: TopologyException: Input geom 1 is invalid: Self-intersection at or near point -381688.06935935974 -1206669.4272876547 at -381688.06935935974 -1206669.4272876547 at ./test.pl line 151.

 ( line 151 is the perl code:   $sth->execute();   )
I isolated which JSON poly was causing the issue, and saved it here:   http://microflush.org/stuff/json/nwsZone.json
I verified the geoJSON, and verified it plots entirely within California using http://geojsonlint.com/
The state of Californina, which I got from NWS, can be found here:  http://microflush.org/stuff/json/CA.json
Can anyone see why this one nwsZone.json polygon is returning the error?

Any help would be great.
Thanks!
Regards,Joseph Spenner


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150225/288a1817/attachment.html>


More information about the postgis-users mailing list