0

I have written a script which reads a CSV file with lat/lon coordinates in WGS84 and inserts them into a table in PostGIS.

What I want to do now is to change the insert query in order to make a transformation of the coordinates from WGS84 to another reference system. My qyestion is if something like this is possible while inserting the data.

I was trying something like this but doesn't work:

   INSERT INTO imgRural(geom) VALUES (ST_Transform(ST_GeomFromText('POINT(23.771111111111 38.013888888889)', 2100)),2100) RETURNING imgId;

What am I missing here?

  • 1
    You need to set the SRID to 4326 before you can transform it. Something like, INSERT INTO imgRural(geom) VALUES (ST_Transform(ST_GeomFromText('POINT(23.771111111111 38.013888888889)', 4326), 2100)) RETURNING imgId; – John Powell Jan 22 '15 at 11:55
  • Thanks for your answer. I followed your suggestion and with some small modification in worked.INSERT INTO imgRural(geom) VALUES (ST_Transform(ST_GeomFromText('POINT(23.771111111111 38.013888888889)',4326),2100)) RETURNING imgId; – user1919 Jan 22 '15 at 11:58
  • 1
    Oh, yes, forgot the comma, sorry. – John Powell Jan 22 '15 at 11:58
1

As John Barca said in his comment: I neglected to set the SRID before the transformation. This worked fine:

   INSERT INTO imgRural(geom) VALUES (ST_Transform
   (ST_GeomFromText('POINT(23.771111111111 38.013888888889)',4326),2100)) 
   RETURNING imgId;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.