11

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.

5
  • 2
    make sure you give your data a SRID that matches the table before trying to insert it.
    – Ian Turton
    Jul 9 '14 at 12:53
  • i dont understand , the srid of my data is the srid of my table ! it is the same , no ? Jul 9 '14 at 13:10
  • 1
    can you show us one of your insert statements?
    – Ian Turton
    Jul 9 '14 at 13:20
  • like this : INSERT INTO borne(num_borne, shape_borne) VALUES(1, POINT(25800 , 256000)); Jul 9 '14 at 13:54
  • 2
    The geometry In your insert statement does not have a srid. That is the cause of the error Jul 10 '14 at 1:50
16

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));
5
  • i dont have some table Jul 9 '14 at 14:04
  • Updated to include your use case. Jul 9 '14 at 14:18
  • it did not work ! Jul 9 '14 at 15:21
  • What is the error message? also, try running: select find_srid('public', 'borne', 'shape_borne'); to make sure that the srid is actually set on the field. Jul 9 '14 at 19:45
  • it's ok! it s working with using INSERT INTO public.borne (num_borne, shape_borne) VALUES (1, ST_SetSRID(ST_MakePoint(25800 , 256000), 26191)); it is mandatory to use ST_SetSRID(ST_MakePoint( ... ) for adding in this table ? for my other table (parcelle) it's wortking with a normal request for exmple : INSERT INTO parcelle(num_parcelle, shape) VALUES(1, POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))); Jul 10 '14 at 10:28
6

If you are typing a geometry's WKT into pgAdmin III, you need to specify the SRID using EWKT syntax, otherwise it defaults to 0.

Type this into the geometry field of pgAdmin III:

SRID=26191;POINT(25800 256000)

Otherwise, @MakinFlippyFloppy has the correct SQL way, using ST_SetSRID.

0

I thin below link can help you, Check out below page ::

http://postgis.org/docs/UpdateGeometrySRID.html

1
  • I already work with this function ! Jul 9 '14 at 13:13

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .