<div dir="ltr"><div><div><div><div><div>If you don't use any topology at all (you don't have data wich should share bondaries),<br></div>you can just use st_makevalid<br></div>something like<br></div>update my_table set (geom) = (ST_makeValid(geom)) ;<br></div><div>for all your table<br></div><div><br></div>If your data is topological, you are in trouble :-/<br><br></div><div>You could try to use Postgis Topology and pray for no error, or use GRASS.<br><br></div>Cheers,<br>Rémi-C<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-02 15:45 GMT+01:00 Luís Miguel Royo Pérez <span dir="ltr"><<a href="mailto:luis.miguel.royo@gmail.com" target="_blank">luis.miguel.royo@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Thank you Rémi,<br>
    <br>
    I think I have mixed up some issues. I thought the error was
    produced by the problematic layer, but is mapa_ruido_dia the
    problem, it's a completly mess :(<br>
    <br>
    I have tried to clean the layer, but I don't know how exactly should
    I proceed. <br>
    <br>
    Can anyone lead me in this task with some links or tips? <br>
    <br>
    Thank you!!<div><div class="h5"><br>
    <br>
    <br>
    <br>
    <div>On 12/02/2014 11:49 AM, Rémi Cura
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>
                <div>Hey,<br>
                </div>
                <div>some common answer about precision issue :<br>
                  <br>
                  <br>
                </div>
                1. : offset your coordinate to gain in precision :<br>
              </div>
              723120.23091093975 4379700.195452339 ->
              120.23091093975XXX , 700.195452339XXXX<br>
            </div>
            2. snap to grid you input data<br>
            <br>
          </div>
          3. check that your input geoms are valid : st_isvalid :
          st_makevalid() <br>
          <br>
        </div>
        Cheers,<br>
        Rémi-C<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2014-12-02 11:45 GMT+01:00 Luís Miguel
          Royo Pérez <span dir="ltr"><<a href="mailto:luis.miguel.royo@gmail.com" target="_blank">luis.miguel.royo@gmail.com</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> Hi everyone,<br>
              <br>
              I'm trying to perform a quite simple analysis in Postgis,
              but I'm facing a TopologyException where there's no
              features.<br>
              <br>
              You can find the data I'm using in this <a href="https://mega.co.nz/#%21pFgnCBoA%21zx-Tb78nPGzL7Fcbw7dMheSbIrMfRJjJ9yV1Qv7Wx6o" target="_blank">link</a>.<br>
              <p>What I try to do is the next:</p>
              <ul>
                <li>First I want to create a buffer for emt_paradas, and
                  the layer valenbisi, and then intersect them, the
                  result I will call "intersect_1".</li>
              </ul>
              <pre><code>    select  st_intersection(buf_emt.st_union,buf_valenbisi.st_union)
    from
    (SELECT  ST_union(st_buffer(emt_paradas.geom, 200)) FROM emt_paradas )as buf_emt,
    (SELECT  ST_union(st_buffer(valenbisi.geom, 200)) FROM valenbisi )as buf_valenbisi</code></pre>
              <ul>
                <li>Second, I want to create a buffer for carril_bici,
                  and intersect with "intersect_1". The result I will
                  call "intersect_2".</li>
              </ul>
              <pre><code>    select  st_intersection(buf_carril_bici.st_union,inter_emt_valenbisi.st_intersection)
    from
    (select  st_intersection(buf_emt.st_union,buf_valenbisi.st_union)
    from
    (SELECT  ST_union(st_buffer(emt_paradas.geom, 200)) FROM emt_paradas )as buf_emt,
    (SELECT  ST_union(st_buffer(valenbisi.geom, 200)) FROM valenbisi )as buf_valenbisi) as intersect_1</code></pre>
              <ul>
                <li>Third, I want to create a buffer for layer ocio and
                  make a difference with "intersect_2". The result I
                  will call: "diff_1".</li>
              </ul>
              <pre><code>    select  st_difference(intersec_2.st_intersection, buf_ocio.st_union)
    from
    (select  st_intersection(buf_carril_bici.st_union,inter_emt_valenbisi.st_intersection)
    from
    (select  st_intersection(buf_emt.st_union,buf_valenbisi.st_union)
    from
    (SELECT  ST_union(st_buffer(emt_paradas.geom, 200)) FROM emt_paradas )as buf_emt,
    (SELECT  ST_union(st_buffer(valenbisi.geom, 200)) FROM valenbisi )as buf_valenbisi) as inter_emt_valenbisi,
    (SELECT  ST_union(st_buffer(carril_bici.geom, 200)) FROM carril_bici )as buf_carril_bici) as intersectionEMT_valenbisi_carrilBici,
    (SELECT  ST_union(st_buffer(ocio.geom, 250)) FROM ocio )as buf_ocio</code></pre>
              <ul>
                <li>Finnaly I want to intersect "diff_1" with layer
                  mapa_ruido_dia, ideally where the field gridcode
                  equals one or two.</li>
              </ul>
              <pre><code>    select 1 as id, st_intersection(diff_1.st_difference, mapa_ruido_dia.geom)
    from
    (select  st_difference(intersectionEMT_valenbisi_carrilBici.st_intersection, buf_ocio.st_union)
    from
    (select  st_intersection(buf_carril_bici.st_union,inter_emt_valenbisi.st_intersection)
    from
    (select  st_intersection(buf_emt.st_union,buf_valenbisi.st_union)
    from
    (SELECT  ST_union(st_buffer(emt_paradas.geom, 200)) FROM emt_paradas )as buf_emt,
    (SELECT  ST_union(st_buffer(valenbisi.geom, 200)) FROM valenbisi )as buf_valenbisi) as inter_emt_valenbisi,
    (SELECT  ST_union(st_buffer(carril_bici.geom, 200)) FROM carril_bici )as buf_carril_bici) as intersectionEMT_valenbisi_carrilBici,
    (SELECT  ST_union(st_buffer(ocio.geom, 250)) FROM ocio )as buf_ocio)as diff_1, mapa_ruido_dia 
     where mapa_ruido_dia.gridcode='1' or mapa_ruido_dia.gridcode='2'

</code></pre>
              Is in this last one query when Postgis show me the
              TopologyException<br>
              <br>
              <pre><code>> Error performing intersection: TopologyException: Input geom 1 is
> invalid: Self-intersection at or near point 723120.23091093975
> 4379700.195452339 at 723120.23091093975 4379700.195452339

<font face="sans-serif">
Any ideas? Thank you very much!</font></code></pre>
            </div>
            <br>
            _______________________________________________<br>
            postgis-users mailing list<br>
            <a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
            <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
postgis-users mailing list
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>