我正在尝试将 SHP 文件放入我的 PostGIS 数据库中,但数据有点偏差。我认为这是因为我使用了错误的 SRID。 PRJ 文件的内容如下:
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]]
这与什么 SRID 相关?更一般地说,如何根据 PRJ 文件中找到的信息查找 SRID?是否有一个查找表列出了所有 SRID 及其“geogcs”等效项?
使用 srid=4269
和 4326 导入的数据结果完全相同。
这是否意味着我使用了错误的 SRID,或者这只是预期的误差范围?
shp 文件来自此处。
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?
The data imported using srid=4269
and 4326 were the exact same results.
Does this mean I'm using the wrong SRID, or is this just expected margin of error?
The shp file is from here.
发布评论
评论(7)
详细说明提喻 的答案是,SRID 有时称为“EPSG”代码。 SRID/EPSG 代码实际上是投影的众所周知的文本表示的简写。
您可以在 SRID 表上进行快速搜索,看看是否可以找到完全匹配或相似的匹配:
从spatial_ref_sys中选择srid、srtext、proj4text WHERE srtext ILIKE '%BLAH%'
以上内容位于http://www.bostongis.com/?content_name=postgis_tut01。
您还可以在 spatialreference.org 上搜索此类内容。搜索工具很原始,因此您可能必须使用 Google 搜索并指定站点,但任何结果都会向您显示 ESRI PRJ 内容、PostGIS SQL INSERT 和一堆其他表示形式。
我认为您的 PRJ 位于:http://spatialreference.org/ref/sr-org/ 15/
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 是一个专门针对这个问题的小网站;粘贴 PRJ 内容,它会尽力找到匹配的 EPSG。他们还有一个网络服务 API。这不是一门精确的科学。他们似乎使用 Lucene 和 EPSG 数据库来进行匹配的文本搜索。
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.
数据似乎是 NAD83,其 SRID 为 4269。您的 PostGIS 数据库有一个
spatial_ref_sys
表,它是 SRID 查找表。如果 SRID 为 4269 (NAD83) 和 4326 (WGS84) 时数据看起来相同,则说明有问题。
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.
去下载 GDAL 实用程序,ogrinfo(它会吐出投影信息)和 ogr2ogr 实用程序非常宝贵。
James 已经给出了 spatialreference.org 的链接。这有助于查找空间参考信息...我假设您在准备好您的 postgis 实例。
说实话,我不认为问题出在 PostGIS 方面。
我通常将数据保存在 PostGIS 数据库的不同 SRID 中。但是,我总是需要投影到输出SRS。您正在显示 OpenStreetMap 预渲染图块,我敢打赌它们是使用 SRID 900913 绘制的 (现在每个人都使用 Google 地图修改后的墨卡托投影来渲染)。
我给您的建议是:
1- 在 OpenLayers 代码中设置正确的投影,该投影与您正在读取的任何图块相匹配。
2.- 将数据库中的数据保存在您想要的任何 SRID 中(当然只要它是正确的)。
3.- 确保您用来从数据生成图像的服务器(ArcGIS Server、Mapserver、GeoServer 或其他任何服务器)重新投影到同一个 SRS。
一切都会匹配。
干杯
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
使用GDAL的OSR Python模块来确定代码:
Use GDAL's OSR Python module to determine the code:
请务必查看:http://www.epsg-registry.org/
使用按过滤器查询选项并输入:North American Datum 1983。
这将产生 ->每股收益:6269。
希望这对你有用。
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.
其他答案更权威,所以我什至犹豫是否添加这个,但对于一个在使用前应验证的简单建议,可以简单地将“SRID”加上文本粘贴到搜索引擎中,即:
当我尝试时,DuckDuckGo 在 EPSG.io 上返回了 SRID 4269 的正确页面作为最佳结果,Bing 和 Google 的表现也几乎一样。
The other answers are more authoritative so I hesitate to even add this, but for a dead-easy suggestion that should be verified before use, one can simply paste "SRID" plus the text into a search engine, i.e.:
When I tried it, DuckDuckGo returned the correct page on EPSG.io for SRID 4269 as the top result, and Bing and Google did almost as well.