<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 2/26/2015 1:40 PM, Joseph Spenner
      wrote:<br>
    </div>
    <blockquote
      cite="mid:494028169.1008609.1424976001027.JavaMail.yahoo@mail.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff;
        font-family:garamond, new york, times, serif;font-size:14px">
        <div dir="ltr" id="yui_3_16_0_1_1424960459142_100383">I ran the
          following against all 4 of my GeoJSON files:</div>
        <div id="yui_3_16_0_1_1424960459142_100261"><br>
        </div>
        <div id="yui_3_16_0_1_1424960459142_100196">SELECT
          ST_IsSimple(ST_GeomFromGeoJSON('@poly'))</div>
        <div id="yui_3_16_0_1_1424960459142_100199">SELECT
          ST_IsValid(ST_GeomFromGeoJSON('@poly'))</div>
        <div id="yui_3_16_0_1_1424960459142_100207">SELECT
          ST_IsValidDetail(ST_GeomFromGeoJSON('@poly'))</div>
        <div id="yui_3_16_0_1_1424960459142_100215">SELECT
          ST_IsValidReason(ST_GeomFromGeoJSON('@poly'))</div>
        <div id="yui_3_16_0_1_1424960459142_100470"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_1_1424960459142_100262">where
          @poly contained each one of the following:</div>
        <div class="" dir="ltr"
          id="yiv7663890579yui_3_16_0_1_1424883046678_72093" style="">
          <div><br class="" style="" clear="none">
          </div>
        </div>
        <div class="" dir="ltr"
          id="yiv7663890579yui_3_16_0_1_1424883046678_72042" style="">
          <div><a moz-do-not-send="true" rel="nofollow" shape="rect"
              class=""
              id="yiv7663890579yui_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>
        <div class="" dir="ltr"
          id="yiv7663890579yui_3_16_0_1_1424883046678_72075" style="">
          <div class="" dir="ltr"
            id="yiv7663890579yui_3_16_0_1_1424883046678_72099" style="">
            <div><a moz-do-not-send="true" rel="nofollow" shape="rect"
                class=""
                id="yiv7663890579yui_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>
          <div class="" dir="ltr"
            id="yiv7663890579yui_3_16_0_1_1424883046678_72146" style="">
            <div id="yui_3_16_0_1_1424960459142_100536"><br>
            </div>
            <div id="yui_3_16_0_1_1424960459142_100588"><a
                moz-do-not-send="true" style="" class="" rel="nofollow"
                shape="rect"
                id="yiv7663890579yui_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 id="yui_3_16_0_1_1424960459142_100531"><a
                moz-do-not-send="true" style="" class="" rel="nofollow"
                shape="rect"
                id="yiv7663890579yui_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 id="yui_3_16_0_1_1424960459142_100530"><br>
            </div>
            <div style="" class=""
              id="yui_3_16_0_1_1424960459142_100530"><br>
            </div>
            <div dir="ltr" id="yui_3_16_0_1_1424960459142_100594"
              style="" class="">The select returned no error.  I tried
              to vary the input slightly to make sure I was using the
              proper syntax, and was able to get errors-- such as:</div>
            <div id="yui_3_16_0_1_1424960459142_100772" dir="ltr"
              style="" class=""><br>
            </div>
            <div id="yui_3_16_0_1_1424960459142_100773" dir="ltr"
              style="" class="">DBD::Pg::st execute failed: ERROR: 
              geometry contains non-closed rings<br style="" class="">
            </div>
            <div id="yui_3_16_0_1_1424960459142_100870" dir="ltr"
              style="" class=""><br>
            </div>
            <div id="yui_3_16_0_1_1424960459142_100869" dir="ltr"
              style="" class="">So, it would seem my geoms are ok.</div>
            <div id="yui_3_16_0_1_1424960459142_100823" dir="ltr"
              style="" class=""><br>
            </div>
            <div id="yui_3_16_0_1_1424960459142_100962" dir="ltr"
              style="" class="">I've not yet tried the "ST_MakeValid".  
              But wouldn't the above indicate they're already valid?</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Yes ST_IsValid coming back true means that the geometry is "valid". 
    (Topology Exceptions are most often thrown during operations on
    invalid geometries - so this test is the first that should be done
    when one occurs...  in almost all cases)<br>
    <br>
    In my (limited) experience - just because 2 geometries are valid,
    doesn't mean that operations on them won't generate issues. <br>
    <br>
    Is it the cast to Geography, ST_Intersection or the ST_Area on the
    ST_Intersection that is throwing the error?<br>
    My guess is going to be the ST_Area on the results of the
    ST_Intersection.<br>
    <br>
    So, is the result of the ST_Intersection of the two geographies
    valid?<br>
    <br>
    Have you perhaps looked at all the involved geometries (since you
    are down to 4) at the point identified by the original Topo  error 
    in order to understand exactly what in the makeup of those
    geometries makes the error remotely possible within the operation
    you are performing on them?  <br>
    <br>
    ST_MakeValid and ST_Buffer adjust the geometry in (frequently
    insignificant) ways that help operations avoid Topos.  But what
    adjustment is likely to avoid the error when using the related valid
    geometries is dependent upon the real cause for the error - and that
    is specific to the geometries at the point identified in the error. 
    Whether those manipulations can validly be applied is dependent upon
    your business use tolerance for those adjustments.  (buffering a
    polygon by 0.00001 will skew calculated area of a polygon but may
    not result in false positives for an Intersects).<br>
    <br>
    Roxanne<br>
    <br>
    <blockquote
      cite="mid:494028169.1008609.1424976001027.JavaMail.yahoo@mail.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff;
        font-family:garamond, new york, times, serif;font-size:14px">
        <div class="" dir="ltr"
          id="yiv7663890579yui_3_16_0_1_1424883046678_72075" style="">
          <div class="" dir="ltr"
            id="yiv7663890579yui_3_16_0_1_1424883046678_72146" style="">
            <div id="yui_3_16_0_1_1424960459142_101214" dir="ltr"
              style="" class=""><br>
            </div>
            <div id="yui_3_16_0_1_1424960459142_101215" dir="ltr"
              style="" class="">Thanks!</div>
            <div id="yui_3_16_0_1_1424960459142_101216" dir="ltr"
              style="" class=""><br style="" class="">
            </div>
            <div id="yui_3_16_0_1_1424960459142_100773" dir="ltr"
              style="" class=""><br style="" class="">
            </div>
          </div>
          <div class="" dir="ltr"
            id="yiv7663890579yui_3_16_0_1_1424883046678_72146" style=""><br
              class="" style="" clear="none">
          </div>
        </div>
        <div id="yui_3_16_0_1_1424960459142_100005"><br>
          <div id="yui_3_16_0_1_1424960459142_100126">
            <br>
          </div>
        </div>
        <br>
        <div id="yui_3_16_0_1_1424960459142_100129" style="font-family:
          garamond, new york, times, serif; font-size: 14px;">
          <div id="yui_3_16_0_1_1424960459142_100128"
            style="font-family: HelveticaNeue, Helvetica Neue,
            Helvetica, Arial, Lucida Grande, sans-serif; font-size:
            16px;">
            <div id="yui_3_16_0_1_1424960459142_100127" dir="ltr">
              <hr id="yui_3_16_0_1_1424960459142_101052" size="1"> <font
                id="yui_3_16_0_1_1424960459142_100130" face="Arial"
                size="2"> <b><span style="font-weight:bold;">From:</span></b>
                Joseph Spenner <a class="moz-txt-link-rfc2396E" href="mailto:joseph85750@yahoo.com"><joseph85750@yahoo.com></a><br>
                <b><span style="font-weight: bold;">To:</span></b>
                PostGIS Users Discussion
                <a class="moz-txt-link-rfc2396E" href="mailto:postgis-users@lists.osgeo.org"><postgis-users@lists.osgeo.org></a> <br>
                <b><span style="font-weight: bold;">Sent:</span></b>
                Thursday, February 26, 2015 8:05 AM<br>
                <b id="yui_3_16_0_1_1424960459142_100132"><span
                    id="yui_3_16_0_1_1424960459142_100131"
                    style="font-weight: bold;">Subject:</span></b> Re:
                [postgis-users] TopologyException: geom is invalid<br>
              </font> </div>
            <div id="yui_3_16_0_1_1424960459142_100143"
              class="y_msg_container"><br>
              <div id="yiv6910395946">
                <div id="yui_3_16_0_1_1424960459142_100142">
                  <div id="yui_3_16_0_1_1424960459142_100141"
                    style="color:#000;background-color:#fff;font-family:garamond,
                    new york, times, serif;font-size:14px;">
                    <div
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30305">Hello,
                      and thanks for the replies!</div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30743">I'll
                      try those suggestions.</div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30742"><br
                        clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30548">Just
                      curiuos though-- which geometry seems to be
                      invalid?  Is it the state poly, or the smaller
                      county/zone poly?  If there was an invalid
                      geometry, wouldn't it always show up for that
                      state or county?  Here's what I observed for the
                      CA issue:</div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30549"><br
                        clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30550">1)
                      I had 3 smaller county poly/geometries in CA. 
                      When performing my query, instead of returning the
                      3 polys, I received the error which I posted in my
                      original thread.  I identified it was 1 of those
                      3.  I deleted that 1 offending geometry from my
                      table.  After doing so, my query against CA turned
                      up the remaining 2, with no errors.  So, that
                      leads me to believe CA is ok.  Or is this not a
                      valid assumption?   Perhaps the location where
                      that offending intersection would have occurred in
                      the CA poly has an issue, and it doesn't get
                      tickled unless the smaller county zone intersects
                      it?</div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30551"><br
                        clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30552">2)
                      I was able to plot the offending county described
                      above in the GeoJSONLint validation page:   <a
                        moz-do-not-send="true" rel="nofollow"
                        shape="rect"
                        id="yiv6910395946yui_3_16_0_1_1424960459142_30556"
                        target="_blank" href="http://geojsonlint.com/">http://geojsonlint.com/</a></div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30624"> 
                      There didn't appear to be any issues.</div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30741"><br
                        clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30732">Thanks!</div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30738"><br
                        clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30739">Regards,</div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30740">Joseph
                      Spenner<br clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30604"><br
                        clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30717"><br
                        clear="none">
                    </div>
                    <div dir="ltr"
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30603"><br
                        clear="none">
                    </div>
                    <div
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30552">
                       </div>
                    <div
                      id="yiv6910395946yui_3_16_0_1_1424960459142_30287"><br
                        clear="none">
                      <div
                        id="yiv6910395946yui_3_16_0_1_1424960459142_30553">
                        <br clear="none">
                      </div>
                    </div>
                    <br clear="none">
                    <div class="qtdSeparateBR"><br>
                      <br>
                    </div>
                    <div class="yiv6910395946yqt4511872611"
                      id="yiv6910395946yqt77936">
                      <div
                        id="yiv6910395946yui_3_16_0_1_1424960459142_30746"
                        style="font-family:garamond, new york, times,
                        serif;font-size:14px;">
                        <div
                          id="yiv6910395946yui_3_16_0_1_1424960459142_30745"
                          style="font-family:HelveticaNeue, Helvetica
                          Neue, Helvetica, Arial, Lucida Grande,
                          sans-serif;font-size:16px;">
                          <div dir="ltr"
                            id="yiv6910395946yui_3_16_0_1_1424960459142_30744">
                            <hr size="1"> <font
                              id="yiv6910395946yui_3_16_0_1_1424960459142_30747"
                              face="Arial" size="2"> <b><span
                                  style="font-weight:bold;">From:</span></b>
                              Rémi Cura <a class="moz-txt-link-rfc2396E" href="mailto:remi.cura@gmail.com"><remi.cura@gmail.com></a><br
                                clear="none">
                              <b><span style="font-weight:bold;">To:</span></b>
                              PostGIS Users Discussion
                              <a class="moz-txt-link-rfc2396E" href="mailto:postgis-users@lists.osgeo.org"><postgis-users@lists.osgeo.org></a> <br
                                clear="none">
                              <b><span style="font-weight:bold;">Cc:</span></b>
                              Joseph Spenner
                              <a class="moz-txt-link-rfc2396E" href="mailto:joseph85750@yahoo.com"><joseph85750@yahoo.com></a> <br
                                clear="none">
                              <b><span style="font-weight:bold;">Sent:</span></b>
                              Thursday, February 26, 2015 1:28 AM<br
                                clear="none">
                              <b><span style="font-weight:bold;">Subject:</span></b>
                              Re: [postgis-users] TopologyException:
                              geom is invalid<br clear="none">
                            </font> </div>
                          <div class="yiv6910395946y_msg_container"
                            id="yiv6910395946yui_3_16_0_1_1424960459142_30853"><br
                              clear="none">
                            <div id="yiv6910395946">
                              <div
                                id="yui_3_16_0_1_1424960459142_100307">
                                <div dir="ltr">
                                  <div>
                                    <div>And also ST_IsSimple (that
                                      precisely check for self
                                      intersection).<br clear="none">
                                    </div>
                                    Cheers,<br clear="none">
                                  </div>
                                  Rémi-C<br clear="none">
                                </div>
                                <div
                                  id="yui_3_16_0_1_1424960459142_100306"
                                  class="yiv6910395946gmail_extra"><br
                                    clear="none">
                                  <div
                                    id="yui_3_16_0_1_1424960459142_100305"
                                    class="yiv6910395946gmail_quote">2015-02-26
                                    8:32 GMT+01:00 BladeOfLight16 <span
                                      dir="ltr"><<a
                                        moz-do-not-send="true"
                                        rel="nofollow" shape="rect"
                                        ymailto="mailto:bladeoflight16@gmail.com"
                                        target="_blank"
                                        href="mailto:bladeoflight16@gmail.com">bladeoflight16@gmail.com</a>></span>:<br
                                      clear="none">
                                    <blockquote
                                      id="yui_3_16_0_1_1424960459142_100304"
                                      class="yiv6910395946gmail_quote"
                                      style="margin:0 0 0
                                      .8ex;border-left:1px #ccc
                                      solid;padding-left:1ex;">
                                      <div
                                        class="yiv6910395946qtdSeparateBR"><br
                                          clear="none">
                                        <br clear="none">
                                      </div>
                                      <div
                                        class="yiv6910395946yqt4173123445"
                                        id="yiv6910395946yqt47029">
                                        <div
                                          id="yui_3_16_0_1_1424960459142_100303"
                                          dir="ltr">
                                          <div
                                            id="yui_3_16_0_1_1424960459142_100302"
class="yiv6910395946gmail_extra">
                                            <div
                                              id="yui_3_16_0_1_1424960459142_100301"
class="yiv6910395946gmail_quote">On Wed, Feb 25, 2015 at 12:14 PM,
                                              Joseph Spenner <span
                                                id="yui_3_16_0_1_1424960459142_100300"
                                                dir="ltr"><<a
                                                  moz-do-not-send="true"
id="yui_3_16_0_1_1424960459142_100299" rel="nofollow" shape="rect"
                                                  ymailto="mailto:joseph85750@yahoo.com"
                                                  target="_blank"
                                                  href="mailto:joseph85750@yahoo.com">joseph85750@yahoo.com</a>></span>
                                              wrote:<br clear="none">
                                              <blockquote
                                                id="yui_3_16_0_1_1424960459142_100315"
class="yiv6910395946gmail_quote" style="margin:0px 0px 0px
                                                0.8ex;border-left:1px
                                                solid
                                                rgb(204,204,204);padding-left:1ex;">
                                                <div
                                                  id="yui_3_16_0_1_1424960459142_100314">
                                                  <div
                                                    id="yui_3_16_0_1_1424960459142_100313"
                                                    style="color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:garamond,
                                                    new york, times,
                                                    serif;font-size:14px;">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 ./<a
                                                      moz-do-not-send="true"
                                                      rel="nofollow"
                                                      shape="rect"
                                                      target="_blank"
                                                      href="http://test.pl/">test.pl</a>
                                                    line 151.<br
                                                      clear="none">
                                                  </div>
                                                </div>
                                              </blockquote>
                                              <div><br clear="none">
                                              </div>
                                              <div>Did you try
                                                ST_IsValid to verify the
                                                geometry is valid
                                                according to the OGC
                                                standard? (See <a
                                                  moz-do-not-send="true"
                                                  rel="nofollow"
                                                  shape="rect"
                                                  target="_blank"
href="http://postgis.net/docs/using_postgis_dbmanagement.html#OGC_Validity">http://postgis.net/docs/using_postgis_dbmanagement.html#OGC_Validity</a>.
                                                ST_IsValidDetail and
                                                ST_IsValidReason are
                                                also helpful in this
                                                regard.) What happens if
                                                you run it through
                                                ST_MakeValid? Be aware
                                                that ST_MakeValid can
                                                sometimes result in
                                                GeometryCollections if
                                                the input shape is
                                                malformed (usually
                                                "rings" without enough
                                                points are that have
                                                different start and end
                                                points).<br clear="none">
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                      <br clear="none">
_______________________________________________<br clear="none">
                                      postgis-users mailing list<br
                                        clear="none">
                                      <a moz-do-not-send="true"
                                        rel="nofollow" shape="rect"
                                        ymailto="mailto:postgis-users@lists.osgeo.org"
                                        target="_blank"
                                        href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br
                                        clear="none">
                                      <a moz-do-not-send="true"
                                        rel="nofollow" shape="rect"
                                        target="_blank"
                                        href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br
                                        clear="none">
                                    </blockquote>
                                  </div>
                                  <br clear="none">
                                </div>
                              </div>
                            </div>
                            <br clear="none">
                            <br clear="none">
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <br>
              <br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
[At other schools] I think the most common fault in general is to teach students how to pass exams instead of teaching them the science.
Donald Knuth</pre>
  </body>
</html>