Wednesday, 22 July 2015

postgis - Problem when calculating longitude and latitude for points


I have a PostGIS database with SRID=900913 (Google Mercator) and I would like to know the latitude and longitude of points.


I use this command:


ST_X(ST_TRANSFORM(the_geom,4283))


Following what is written here, but it doesn't work. I get the error:


ERROR: AddToPROJ4SRSCache: Cannot find SRID (4283) in spatial_ref_sys
SQL state: XX000.

I tried to add 4283 in the spatial_ref_sys:


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"]]');

But I still have the same error.


What does that mean?




Answer



The ST_Transform function takes the output coordinate system as the second parameter - see ST_Transform. The input co-ordinates should already be stored in the GEOMETRY_COLUMNS table / view.


Also, you seem to have the SRID wrong, it is 4326 for standard WGS84 lat/lon.


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