<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">Well,I have understood a few things since my first message :</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">1) If SRID = 0 for a geometry column, even if a shapefile has a SRID different from 0, it is lost after the import in PostGIS.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">That is why I was wondering : how can I select geometries initially set with a specific SRID between all my geometries with different SRIDs?</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">One idea is to complete a column with the original SRID after the import. Then request on this column to select geometries with a specific SRID. <br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">But, but given the particularities of my work, the most practical solution is to create one column per SRID.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">At last, initially, if I had a SRID for each feature in a column with srid = 0 (returns by st_asewkt(geom)), it is because I copied and pasted geometries from a column that had an SRID into that column that did not. But the SRID was kept anyway.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">I hope I am clear,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:large">Thanks for your answer.<br></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><br><div><i style="font-size:small">----------</i></div><div><font size="1"><i>Mathias Cunault</i><br></font></div></div></div><div><font size="1"><i>référent SIG / Admin Caviar<br></i><i><i>Inrap Tours - </i>148 av. Maginot<br>37000 TOURS<br>06 32 05 98 96</i></font><font size="1"><br></font></div><div><font size="1">abonn</font><i style="font-size:small"></i><font size="1">ez-vous à la lettre d'information de l'Inrap : <a href="http://www.inrap.fr/newsletter.php" target="_blank">http://ww</a></font><font size="1"><a href="http://www.inrap.fr/newsletter.php" target="_blank">w.inrap.fr/newsletter.php</a></font><br></div></div></div></div></div></div></div></div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 17 mai 2022 à 23:12, Regina Obe <<a href="mailto:lr@pcorp.us">lr@pcorp.us</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_8108115456576898518WordSection1"><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">1) Are you sure QGIS is not setting the SRID to 2154 for some reason <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">2) Are you sure your QGIS load is not erroring out for some reason, e.g. you file is not multipolygon but instead POINT or POLYGON.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">3) Also to allow mixed geometry SRID, you don’t need to pass in the srid.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">This is slightly shorter and clearer in purpose:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><pre><span class="gmail-m_8108115456576898518gmail-hljs-keyword">alter</span><code> </code><span class="gmail-m_8108115456576898518gmail-hljs-keyword">table</span><code> activite.prescription<u></u><u></u></code></pre><pre><span class="gmail-m_8108115456576898518gmail-hljs-keyword">alter</span><code> </code><span class="gmail-m_8108115456576898518gmail-hljs-keyword">column</span><code> geom type geometry(MULTIPOLYGON);<u></u><u></u></code></pre><pre><code><u></u> <u></u></code></pre><pre><code><u></u> <u></u></code></pre><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><div style="border-color:currentcolor currentcolor currentcolor blue;border-style:none none none solid;border-width:medium medium medium 1.5pt;padding:0in 0in 0in 4pt"><div><div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in"><p class="MsoNormal"><b><span style="font-size:11pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11pt;font-family:"Calibri",sans-serif"> postgis-users [mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a>] <b>On Behalf Of </b>mathias cunault<br><b>Sent:</b> Friday, May 13, 2022 8:06 AM<br><b>To:</b> <a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br><b>Subject:</b> [postgis-users] can't import a shapefile with different SRID in a geometry column<u></u><u></u></span></p></div></div><p class="MsoNormal"><u></u> <u></u></p><div><div><div><div><p><strong><span style="font-size:18pt;font-family:"Verdana",sans-serif">PostgreSQL 13, PostGIS 3, QGIS 3.22</span></strong><span style="font-size:18pt;font-family:"Verdana",sans-serif"><u></u><u></u></span></p><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">In a table, I had a geometry column geom with a SRID 2154.<br>Now I have to store geometries with different SRIDs in geom. So I did :<u></u><u></u></span></p><pre><span class="gmail-m_8108115456576898518gmail-hljs-keyword">alter</span><code> </code><span class="gmail-m_8108115456576898518gmail-hljs-keyword">table</span><code> activite.prescription<u></u><u></u></code></pre><pre><span class="gmail-m_8108115456576898518gmail-hljs-keyword">alter</span><code> </code><span class="gmail-m_8108115456576898518gmail-hljs-keyword">column</span><code> geom type geometry(MULTIPOLYGON, </code><span class="gmail-m_8108115456576898518gmail-hljs-number">0</span><code>),<u></u><u></u></code></pre><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">to be able to store different SRIDs, replacing 2154 with 0.<u></u><u></u></span></p><pre><span class="gmail-m_8108115456576898518gmail-hljs-keyword">SELECT</span><code> Find_SRID(</code><span class="gmail-m_8108115456576898518gmail-hljs-string">'activite'</span><code>, </code><span class="gmail-m_8108115456576898518gmail-hljs-string">'prescription'</span><code>, </code><span class="gmail-m_8108115456576898518gmail-hljs-string">'geom'</span><code>)<u></u><u></u></code></pre><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">returns 0 as expected.<u></u><u></u></span></p><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">Now I try to upload a shapefile with a SRID 5490 using QGIS and the plugin </span><code><span style="font-size:10pt">export to PostgreSQL</span></code><span style="font-size:18pt;font-family:"Verdana",sans-serif">. (The shapefile has the correct .prj file)<u></u><u></u></span></p><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">If the shp is imported correctly, even the geometry, its SRID is "converted" in 2154. It is not a reprojection but just a ununderstandable change. No trigger is activated.<u></u><u></u></span></p><pre><span class="gmail-m_8108115456576898518gmail-hljs-keyword">select</span><code> </code><span class="gmail-m_8108115456576898518gmail-hljs-keyword">distinct</span><code> st_srid(geom) </code><span class="gmail-m_8108115456576898518gmail-hljs-keyword">from</span><code> activite.prescription<u></u><u></u></code></pre><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">returns just <strong><span style="font-family:"Verdana",sans-serif">one</span></strong> SRID 2154!<u></u><u></u></span></p><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">When I load the layer in QGIS choosing 5490 to display the feature, the layer is indeed empty.<u></u><u></u></span></p><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">When I run a query like </span><code><span style="font-size:10pt">select st_setsrid(geom)...</span></code><span style="font-size:18pt;font-family:"Verdana",sans-serif"> applied to the feature imported, it returns 2154 so to speak the SRID initially existing.<u></u><u></u></span></p><p><span style="font-size:18pt;font-family:"Verdana",sans-serif">Why can't I keep the different SRIDs ?<u></u><u></u></span></p></div></div></div><div><div><div><div><div><div><div><div><div><div><div><div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal"><i>----------</i><u></u><u></u></p></div><div><p class="MsoNormal"><i><span style="font-size:7.5pt">Mathias Cunault</span></i><u></u><u></u></p></div></div></div><div><p class="MsoNormal"><i><span style="font-size:7.5pt">référent SIG / Admin Caviar<br>Inrap Tours - 148 av. Maginot<br>37000 TOURS<br>06 32 05 98 96</span></i><u></u><u></u></p></div><div><p class="MsoNormal"><span style="font-size:7.5pt">abonnez-vous à la lettre d'information de l'Inrap : <a href="http://www.inrap.fr/newsletter.php" target="_blank">http://ww</a><a href="http://www.inrap.fr/newsletter.php" target="_blank">w.inrap.fr/newsletter.php</a></span><u></u><u></u></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>_______________________________________________<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="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote></div>