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

蹲街弑〆低调 提交于 2019-11-30 10:20:27

问题


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


回答1:


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/




回答2:


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.




回答3:


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.




回答4:


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




回答5:


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')



回答6:


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.



来源:https://stackoverflow.com/questions/1541202/how-do-you-know-what-srid-to-use-for-a-shp-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!