<html><body><div style="color:#000; background-color:#fff; font-family:garamond, new york, times, serif;font-size:14px"><div id="yiv8137684739"><div id="yui_3_16_0_1_1424904546947_3637"><div id="yui_3_16_0_1_1424904546947_3636" style="color:#000;background-color:#fff;font-family:garamond, new york, times, serif;font-size:14px;"><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_71979" style="">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:</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72007" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72008" style="">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.<br class="yiv8137684739" style="" clear="none">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.</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72041" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72518" style="">Again, the query I'm doing:</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72519" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72520" style=""> 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<br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72660" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72661" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72662" style="">Where
$jsonPoly contains the JSON from the MN.json link below, and the select
from dynamic.polys would return the mnz091.json below.</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72663" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72664" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72521" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72093" style="">MN zone (from NWS)<br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72042" style=""><a rel="nofollow" shape="rect" class="yiv8137684739" id="yiv8137684739yui_3_16_0_1_1424883046678_72073" style="" target="_blank" href="http://microflush.org/stuff/json/MN.json">http://microflush.org/stuff/json/MN.json</a></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72075" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72098" style="">The NWS weather region zone:</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72099" style=""><a rel="nofollow" shape="rect" class="yiv8137684739" id="yiv8137684739yui_3_16_0_1_1424883046678_72112" style="" target="_blank" href="http://microflush.org/stuff/json/mnz091.json">http://microflush.org/stuff/json/mnz091.json</a></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72146" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72147" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72148" style="">Everything I'm using was downloaded and geocoded from here:</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72149" style=""><a rel="nofollow" shape="rect" class="yiv8137684739" id="yiv8137684739yui_3_16_0_1_1424883046678_72150" style="" target="_blank" href="http://www.nws.noaa.gov/geodata/">http://www.nws.noaa.gov/geodata/</a></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72168" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72169" style="">The State zones:</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72189" style=""> <a rel="nofollow" shape="rect" class="yiv8137684739" id="yiv8137684739yui_3_16_0_1_1424883046678_72205" style="" target="_blank" href="http://www.nws.noaa.gov/geodata/catalog/national/html/us_state.htm">http://www.nws.noaa.gov/geodata/catalog/national/html/us_state.htm</a></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72231" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72232" style="">The NWS regions:</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72233" style=""> <a rel="nofollow" shape="rect" class="yiv8137684739" id="yiv8137684739yui_3_16_0_1_1424883046678_72405" style="" target="_blank" href="http://www.nws.noaa.gov/geodata/catalog/national/html/us_region.htm">http://www.nws.noaa.gov/geodata/catalog/national/html/us_region.htm</a></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72569" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72552" style="">I have several other state queries using this exact setup, but these appear to be the only 2 states giving me problems.</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72570" style="">I went through all the other states, and haven't had any issue with any others.</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72682" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72683" style=""><div id="yui_3_16_0_1_1424904546947_3646">If what I'm doing isn't clear, I can explain further.</div><div id="yui_3_16_0_1_1424904546947_3725"><br></div><div id="yui_3_16_0_1_1424904546947_3726" dir="ltr">Again, any help would be appreciated! Free beer if you visit Tucson.<br></div></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72684" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72685" style="">Thanks!</div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72686" style=""><br class="yiv8137684739" style="" clear="none"></div><div class="yiv8137684739" dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_72687" style="">Regards,</div>Joseph Spenner<div id="yiv8137684739yui_3_16_0_1_1424896411866_10241"><br clear="none"><div id="yiv8137684739yui_3_16_0_1_1424896411866_10309">
<br clear="none"></div></div><br clear="none"> <div class="qtdSeparateBR"><br><br></div><div class="yiv8137684739yqt6931429235" id="yiv8137684739yqt68793"><div id="yiv8137684739yui_3_16_0_1_1424896411866_10313" style="font-family:garamond, new york, times, serif;font-size:14px;"> <div id="yiv8137684739yui_3_16_0_1_1424896411866_10312" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424896411866_10311"> <hr size="1"> <font id="yiv8137684739yui_3_16_0_1_1424896411866_10315" face="Arial" size="2"> <b><span style="font-weight:bold;">From:</span></b> Joseph Spenner <joseph85750@yahoo.com><br clear="none"> <b><span style="font-weight:bold;">To:</span></b> "'PostGIS Users Discussion'" <postgis-users@lists.osgeo.org> <br clear="none"> <b><span style="font-weight:bold;">Sent:</span></b> Wednesday, February 25, 2015 10:14 AM<br clear="none"> <b><span style="font-weight:bold;">Subject:</span></b> TopologyException: geom is invalid<br clear="none"> </font> </div> <div class="yiv8137684739y_msg_container" id="yiv8137684739yui_3_16_0_1_1424896411866_10319"><br clear="none"><div id="yiv8137684739"><div id="yiv8137684739yui_3_16_0_1_1424896411866_10318"><div id="yiv8137684739yui_3_16_0_1_1424896411866_10317" style="color:#000;background-color:#fff;font-family:garamond, new york, times, serif;font-size:14px;"><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3031"><span>Hello,</span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3312"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3313">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:</span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3197"><br clear="none"><span></span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3169"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200">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</span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3233"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3432">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.<br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3449"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3311">However, yesterday I had a query which resulted in the following error:</div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3260"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3259">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.<br class="yiv8137684739" style="" clear="none">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.<br class="yiv8137684739" style="" clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3286"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3297"> ( line 151 is the perl code: $sth->execute(); )</div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3310"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3309">I isolated which JSON poly was causing the issue, and saved it here: <a rel="nofollow" shape="rect" id="yiv8137684739yui_3_16_0_1_1424883046678_3337" target="_blank" href="http://microflush.org/stuff/json/nwsZone.json">http://microflush.org/stuff/json/nwsZone.json</a></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3339"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3518">I verified the geoJSON, and verified it plots entirely within California using <a rel="nofollow" shape="rect" id="yiv8137684739yui_3_16_0_1_1424883046678_3520" target="_blank" href="http://geojsonlint.com/">http://geojsonlint.com/</a></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3522"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3554">The state of Californina, which I got from NWS, can be found here: <a rel="nofollow" shape="rect" id="yiv8137684739yui_3_16_0_1_1424883046678_3584" target="_blank" href="http://microflush.org/stuff/json/CA.json">http://microflush.org/stuff/json/CA.json</a></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3615"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3616">Can anyone see why this one nwsZone.json polygon is returning the error?</div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3617"><br clear="none"></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3343"><br clear="none"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200"></span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3222"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200">Any help would be great.</span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3686"><br clear="none"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200"></span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3682"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200">Thanks!</span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3680"><br clear="none"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200"></span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3681"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200">Regards,</span></div><div dir="ltr" id="yiv8137684739yui_3_16_0_1_1424883046678_3683"><span id="yiv8137684739yui_3_16_0_1_1424883046678_3200">Joseph Spenner</span><br clear="none"></div><div id="yiv8137684739yui_3_16_0_1_1424883046678_2934"><br clear="none"><div id="yiv8137684739yui_3_16_0_1_1424883046678_3112">
<br clear="none"></div></div></div></div></div><br clear="none"><br clear="none"></div> </div> </div></div> </div></div></div></div></body></html>