Sunday, 10 May 2015

postgresql - How to get the coordinate system from a PostGIS database?


My question is probably amazinlgy stupid, but I can't find the answer myself.


I would like to extract from a database the latitude and longitude of points. For now, I'm getting x(the_geom) and y(the_geom), and I would like to know what is the coordinate system of the results I get.


How can I know this?



Answer



To get the coordinate system of your table use the following:



SELECT ST_SRID(the_geom) FROM your_table_name LIMIT 1;




For your second question, I am not sure if EPSG:4283 is by default defined in spatial_ref_sys table. In case it is not, you can use a INSERT command. This definition is from spatialreference.org:


INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 94283, 'epsg', 4283, '+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ', 'GEOGCS["GDA94",DATUM["Geocentric_Datum_of_Australia_1994",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6283"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4283"]]');

Now use the ST_Transform(the_geom,4283) command.


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...