Tuesday, January 29, 2008

Transformation from one Coordinate System to Another

The Problem
We had some data that we knew was some kind of geographical data. But we didn't know which coordinate system it was in! We needed to convert it into the GPS coordinate system which refers to the longitudes and latitudes of that location.

Someone made a very reasonable guess that the data may be in the NY Plane coordinate system with SRID 2263. Now I needed to figure out how to transform the data from one coordinate system to another using PostGIS.

(1) Used the function makepoint to group x and y of the unknown coordinate system.
(2) setsrid of that point to 2263 to tell the system the (supposed) coordinate system to 2263.
(3) transform-ed the point to 4326 coordinates. 4326 is the srid for the GPS Coordinate system.

The resulting query was
select transform(setsrid(makepoint(unknownx, unknowny), 2263), 4326) as the_point from location_tbl;

Yippee!

1 comment:

Sumit said...

Ye sab to theek hai, but sawal to ye hai ki nandini ko gussa kyon aata hai?