[postgis-users] ERROR: Operation on two geometries with different SRIDs

Nicolas Ribot nicolas.ribot at gmail.com
Mon Nov 7 06:35:49 PST 2011


On 7 November 2011 15:07, Stefan Schwarzer <stefan.schwarzer at unep.org> wrote:
> Hi there,
>
> I am somewhat fighting with the projection of my file.
>
> I have a file for Morocco, which, after ArcMap, has the following projection:
>
>       Projected Coordinate System:     zone1
>       Projection:      Lambert_Conformal_Conic
>       False_Easting:   500000.00000000
>       False_Northing:  300000.00000000
>       Central_Meridian:        -5.40000000
>       Standard_Parallel_1:     34.86600000
>       Standard_Parallel_2:     31.72500000
>       Scale_Factor:    1.00000000
>       Latitude_Of_Origin:      33.30000000
>       Linear Unit:     Meter
>       Geographic Coordinate System:    GCS_Merchich_Degree
>       Datum:   D_Merchich
>
> After looking around, it seems to be the EPSG 26191 (http://spatialreference.org/ref/epsg/26191/).
>
> Now, trying to import it with:
>
>       shp2pgsql -s EPSG:26191 -I -D morocco.shp morocco > morocco.sql
>       psql -U xxxx my_database < morocco.sql
>
>
> I can see in the SQL file that the SRID is set to -1. If I change this to 26191, and try to import it then, it gives me an error message:
>
>       ERROR:  new row for relation "morocco" violates check constraint "enforce_srid_the_geom"
>

Hi,
Can you explicitly drop the table before re-running the SQL ?

>
> So, I changed the SRID in the geometry_columns manually.
>
> But when trying to map the layer, I receive the error messsage:
>
>        ERROR: Operation on two geometries with different SRIDs
>
>

It is not enough to update the geometry_columns. You also have to
update internal geometries SRID:
update mytable set geom = set_srid(geom).

(looking at the manual, I also see: updateGeometrySrid, that manages
all operations (metadata, constraints and data, did not know this one
:) )

> My Mapserver.map file show only SQLs with 26191, for projection of main document, as well as SQLs such as:
>
>        DATA 'the_geom FROM morocco USING UNIQUE gid USING srid=26191'
>
>
> Extent and units of the mapserver file have been changed to the proper extent/units.
>
> So, I am confused about where the problem comes from. It would be great if someone could give me a hint where the error lies.
>
> Thanks a lot!
>

Nicolas



More information about the postgis-users mailing list