Tuesday, April 21, 2009

How to add SVY21 coordinate system to PostGIS

SVY21 projection does not come with the default installation of my PostGIS 1.3.5 running on PostgreSQL 8.3. If you have geometries with SVY21 easting and northing coordinates and you need to do coordinate transformation e.g. between SVY21 and latitude/longitude in PostGIS, then you have to insert the SVY21 projection parameters into the spatial_ref_sys table in your database. The parameters are a pain to type in. Fortunately, there is a website http://spatialreference.org where you can simply copy the SQL INSERT statement and execute it in the PgAdmin GUI or the PSQL command prompt. 

The exact link to the SVY21 SQL INSERT statement is here below:

Below is the actual statement:
INSERT into spatial_ref_sys  ( srid,  auth_name,  auth_srid,  proj4text,  srtext )  values  (  93414,  'epsg',  3414,  '+proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m +no_defs ',  'PROJCS["SVY21 / Singapore TM",GEOGCS["SVY21",DATUM["SVY21",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6757"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4757"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]], PROJECTION["Transverse_Mercator"], PARAMETER["latitude_of_origin",1.366666666666667], PARAMETER["central_meridian",103.8333333333333], PARAMETER["scale_factor",1], PARAMETER["false_easting",28001.642], PARAMETER["false_northing",38744.572], AUTHORITY["EPSG","3414"], AXIS["Easting",EAST],AXIS["Northing",NORTH]]' );
Simply execute the statement to add in the SVY21 projection to your PostGIS database. The SRID for SVY21 is 93414 here. 

No comments:

Post a Comment