[postgis-users] can't import a shapefile with different SRID in a geometry column

mathias cunault mathias.cunault at inrap.fr
Wed May 18 01:07:42 PDT 2022


Well,I have understood a few things since my first message :
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.
That is why I was wondering : how can I select geometries initially set
with a specific SRID between all my geometries with different SRIDs?

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.
But, but given the particularities of my work, the most practical solution
is to create one column per SRID.

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.

I hope I am clear,
Thanks for your answer.

*----------*
*Mathias Cunault*

*référent SIG / Admin Caviar*

*Inrap Tours - 148 av. Maginot37000 TOURS06 32 05 98 96*
abonnez-vous à la lettre d'information de l'Inrap : http://ww
<http://www.inrap.fr/newsletter.php>w.inrap.fr/newsletter.php
<http://www.inrap.fr/newsletter.php>


Le mar. 17 mai 2022 à 23:12, Regina Obe <lr at pcorp.us> a écrit :

> 1) Are you sure QGIS is not setting the SRID to 2154 for some reason
>
> 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.
>
>
>
> 3) Also to allow mixed geometry SRID, you don’t need to pass in the srid.
>
>
>
> This is slightly shorter and clearer in purpose:
>
>
>
> alter table activite.prescription
>
> alter column geom type geometry(MULTIPOLYGON);
>
>
>
>
>
>
>
>
>
> *From:* postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] *On
> Behalf Of *mathias cunault
> *Sent:* Friday, May 13, 2022 8:06 AM
> *To:* postgis-users at lists.osgeo.org
> *Subject:* [postgis-users] can't import a shapefile with different SRID
> in a geometry column
>
>
>
> *PostgreSQL 13, PostGIS 3, QGIS 3.22*
>
> In a table, I had a geometry column geom with a SRID 2154.
> Now I have to store geometries with different SRIDs in geom. So I did :
>
> alter table activite.prescription
>
> alter column geom type geometry(MULTIPOLYGON, 0),
>
> to be able to store different SRIDs, replacing 2154 with 0.
>
> SELECT Find_SRID('activite', 'prescription', 'geom')
>
> returns 0 as expected.
>
> Now I try to upload a shapefile with a SRID 5490 using QGIS and the plugin export
> to PostgreSQL. (The shapefile has the correct .prj file)
>
> 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.
>
> select distinct st_srid(geom) from activite.prescription
>
> returns just *one* SRID 2154!
>
> When I load the layer in QGIS choosing 5490 to display the feature, the
> layer is indeed empty.
>
> When I run a query like select st_setsrid(geom)... applied to the feature
> imported, it returns 2154 so to speak the SRID initially existing.
>
> Why can't I keep the different SRIDs ?
>
>
>
> *----------*
>
> *Mathias Cunault*
>
>
>
>
> *référent SIG / Admin CaviarInrap Tours - 148 av. Maginot37000 TOURS06 32
> 05 98 96*
>
> abonnez-vous à la lettre d'information de l'Inrap : http://ww
> <http://www.inrap.fr/newsletter.php>w.inrap.fr/newsletter.php
> <http://www.inrap.fr/newsletter.php>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20220518/5392c6d5/attachment.htm>


More information about the postgis-users mailing list