[postgis-users] TopologyException: geom is invalid
Joseph Spenner
joseph85750 at yahoo.com
Wed Feb 25 14:50:33 PST 2015
More info.. I found 1 more state with this issue: Minnesota. The JSON for the state and the poly from the query are much smaller, so perhaps easier to spot the error. But returning a similar error:
DBD::Pg::st execute failed: ERROR: Error performing intersection: TopologyException: Input geom 0 is invalid: Self-intersection at or near point 1543100.5176146738 389360.239110158 at 1543100.5176146738 389360.239110158 at ./test.pl line 157.
DBD::Pg::st execute failed: ERROR: Error performing intersection: TopologyException: Input geom 0 is invalid: Self-intersection at or near point 1543100.5176146738 389360.239110158 at 1543100.5176146738 389360.239110158 at ./test.pl line 157.
Again, the query I'm doing:
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
Where $jsonPoly contains the JSON from the MN.json link below, and the select from dynamic.polys would return the mnz091.json below.
MN zone (from NWS)
http://microflush.org/stuff/json/MN.json
The NWS weather region zone:http://microflush.org/stuff/json/mnz091.json
Everything I'm using was downloaded and geocoded from here:http://www.nws.noaa.gov/geodata/
The State zones: http://www.nws.noaa.gov/geodata/catalog/national/html/us_state.htm
The NWS regions: http://www.nws.noaa.gov/geodata/catalog/national/html/us_region.htm
I have several other state queries using this exact setup, but these appear to be the only 2 states giving me problems.I went through all the other states, and haven't had any issue with any others.
If what I'm doing isn't clear, I can explain further.
Again, any help would be appreciated! Free beer if you visit Tucson.
Thanks!
Regards,Joseph Spenner
From: Joseph Spenner <joseph85750 at yahoo.com>
To: "'PostGIS Users Discussion'" <postgis-users at lists.osgeo.org>
Sent: Wednesday, February 25, 2015 10:14 AM
Subject: TopologyException: geom is invalid
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/052bfce9/attachment.html>
More information about the postgis-users
mailing list