How do you know what SRID to use for a shp file?

I am trying to put a SHP file into my PostGIS database, the the data is just a little off. I think this is because I am using the wrong SRID. The contents of the PRJ file are as follows:

GEOGCS["GCS_North_American_1983",
DATUM["D_North_American_1983",
SPHEROID["GRS_1980",6378137.0,298.257222101]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]]

What SRID does this correlate to? And more generally, how can I look up the SRID based on the information found in the PRJ file? Is there a lookup table somewhere that lists all SRID's and their 'geogcs' equivalents?

For reference, here is an image of some of the data imported using srid=4269 (I also tried 4326 and got the exact same results):

image http://img245.imageshack.us/img245/2545/4326sand.png

The yellow is my data imported from the SHP, and the background is from openlayers (from the geodjango admin). Does this mean I'm using the wrong SRID, or is this just expected margin of error?

The shp file is from here

Answers


To elaborate on synecdoche's answer, the SRID is sometimes called an "EPSG" code. The SRID/EPSG code is a defacto short-hand for the Well-Known-Text representations of projections.

You can do a quick search on the SRID table to see if you can find an exact or similar match: SELECT srid, srtext, proj4text FROM spatial_ref_sys WHERE srtext ILIKE '%BLAH%'

Above was found at http://www.bostongis.com/?content_name=postgis_tut01.

You can also search on spatialreference.org for these kinds of things. The search tool is primitive so you may have to use a Google search and specify the site, but any results will show you the ESRI PRJ contents, the PostGIS SQL INSERT, and a bunch of other representations.

I think your PRJ is at: http://spatialreference.org/ref/sr-org/15/


Prj2EPSG is a small website aimed at exactly this problem; paste in the PRJ contents and it does its best to find a matching EPSG. They also have a web service API. It's not an exact science. They seem to use Lucene and the EPSG database to do text searches for matches.


The data seems to be NAD83, which has an SRID of 4269. Your PostGIS database has a spatial_ref_sys table which is the SRID lookup table.

If the data looks the same with an SRID of 4269 (NAD83) and 4326 (WGS84), then there's something wrong.


Go and download the GDAL utilities , the ogrinfo (which would spit the projection information) and ogr2ogr utilities are invaluable.

James gave already a link to spatialreference.org. That helps to find spatial reference information... I assume you did load the spatial_ref_sys.sql when you prepared your postgis instance.

And to be honest, I don't think the problem is in the PostGIS side of things.

I usually keep my data in different SRIDs in my PostGIS dbs. However, I always need to project to the output SRS. You are showing OpenStreetMap pre-rendered tiles, and I bet they have been drawn using SRID 900913 (the Google Map's modified mercator projection that now everyone uses to render).

My recommendation to you is:

1- Set the right projection in the OpenLayers code which matches whatever tiles you are reading from.

2.- Keep the data in the database in whatever SRID you want (as long as it is correct of course).

3.- Make sure the server you are using to generate the images from your data (ArcGIS Server, Mapserver, GeoServer or whatever it is) is reprojecting to that same SRS.

Everything will match.

Cheers


Use GDAL's OSR Python module to determine the code:

from osgeo import osr

srsWkt = '''GEOGCS["GCS_North_American_1983",
DATUM["D_North_American_1983",
SPHEROID["GRS_1980",6378137.0,298.257222101]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]]'''

# Load in the projection WKT
sr = osr.SpatialReference(srsWkt)

# Try to determine the EPSG/SRID code
res = sr.AutoIdentifyEPSG()
if res == 0: # success
    print('SRID=' + sr.GetAuthorityCode(None))
    # SRID=4269
else:
    print('Could not determine SRID')

Be sure to take a look at: http://www.epsg-registry.org/

Use the Query by Filter option and enter: North American Datum 1983.

This yields -> EPSG:6269.

Hope this works for you.


Need Your Help

Is SQL IN bad for performance?

sql sql-server-2000

I have a query doing something like:

How to choose the cascade file for face detection?

opencv face-detection

I am a freshman for face detection. These days I try to compile the OpenCV2.1 code for face detection. I found that there are about 4 cascade files for front face detection, which are "