Wednesday, 17 August 2016

coordinate system - Problem with Geometry SRID in PostGIS


I ceated my table (borne) in PostGIS


id_borne serial NOT NULL,
num_borne character varying,

shape_borne geometry

I successfully changed the SRID of my table using


select UpdateGeometrySRID('public', 'borne', 'shape_borne', 26191) ;

The old SRID was 0.


The problem is that when I try to add a new element to my table borne I have this message error:


geometry srid (0) does not match column srid (26191)




enter image description here


That is my problem! The SRID is updated but when I try to add a new point, I get this message.



Answer



What's happening is that the data you are trying to insert does not have an SRID assigned. To assign one, try wrapping the inserted geometry in your insert statement with ST_SetSRID(). E.g.,


INSERT INTO public.borne (num_borne, shape_borne) 
(SELECT num_borne, ST_SetSRID(shape_borne, 26191)
FROM public.sometable);

or


INSERT INTO public.borne (num_borne, shape_borne) 

VALUES (1, ST_SetSRID(ST_MakePoint(25800 , 256000), 26191));

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...