[GIS] Adding SRID 3857 to spatial_ref_sys

coordinate systempostgispostgresqlsrid

My application is throwing the following error:

DatabaseError: GetProj4StringSPI: Cannot find SRID (3857) in spatial_ref_sys

I'm guessing (as stated above) that I need to add the SRID 3857 to the spatial_ref_sys.
Looking at my notes from a previous project I've accomplished this in the past by doing the following:

Adding an entry for that SRID to the epsg file, then

Running the following from python shell

from django.contrib.gis.utils import add_postgis_srs

add_postgis_srs(3857)

My problem then becomes, I don't know what the epsg entry should be for 3857.

Am I approaching this problem correctly?

If so, does anyone know what the epsg entry for 3857 should be?

Is it just the same as 900913 (also spherical mercator)?
In other words, could I just replace 900913 with 3857 in the following?

<900913> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs

Best Answer

Yes it is just the same. Web Mercator goes by 3 different srids (900913 and 3857 being two of them).

I'm puzzled you don't have it. 3857 as I recall has been packaged with PostGIS for quite some time. Which PostGIS version are you running?

SELECT postgis_full_version();
Related Question