我的应用程序应该使用什么 SRID 以及如何使用?

发布于 2024-10-12 11:19:13 字数 378 浏览 1 评论 0 原文

我将 PostgreSQL 与 PostGIS 一起使用。我的所有数据都已经附加了十进制纬度/经度(即 -87.34554 33.12321),但要使用 PostGIS,我需要将其转换为某种类型的 SRID。 我的大多数查询都是在查找特定半径内的数据。

我应该使用什么 SRID?我已经创建了一个 SRID 4269 的几何列。 在这个例子中: 链接文本作者正在转换 SRID 4269 到 SRID 32661。我对如何以及何时使用这些 SRID 感到非常困惑。任何有关该主题的精简版都将不胜感激。

I'm using PostgreSQL with PostGIS. All my data has already decimal lat/long attached to it (i.e. -87.34554 33.12321) but to use PostGIS I need to convert it to a certain type of SRID.
The majority of my queries are looking for data inside a certain radius.

What SRID should I use? I created already a geometry column with SRID 4269.
In this example:
link text the author is converting SRID 4269 to SRID 32661. I'm very confused about how and when to use these SRIDs. Any lite on the subject would be truly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

窗影残 2024-10-19 11:19:13

只要您不打算将数据重新投影/转换到另一个坐标系,从技术上讲,您使用什么坐标系并不重要。然而,假设您不想丢弃重要的元数据,并且确实想要对其进行转换,那么您将需要确保分配的 srid 与数据匹配,以便 postgis 知道到时候该做什么。

那么为什么要从 epsg:4269 重新投影呢?答案是因为某些类型的查询(例如距离)在这个“未投影”的世界中没有意义。您的单位采用十进制度,直接测量 x 十进制度是不同的实际距离,具体取决于您在地球上的位置。

在上面的示例中,有人使用 epsg:32661 因为他们相信这会给他们带来更好的准确性如果您的数据位于地球的特定区域,您可以选择适合该区域的准确投影。如果它跨越整个全球,您必须选择一个能够满足您需求的投影。

现在幸运的是,PostGIS 有一些方法可以让这一切变得更容易。对于近似距离,您可以使用 st_distance_sphere 函数,正如您可能猜到的那样,它假设地球是一个球体。或者更准确的 st_distance_spheroid。使用这些,您不需要重新投影,并且除了边缘情况外,您可能可以很好地进行距离查询。新版本的 PostGIS 还允许您使用 地理列

tl;dr - 使用 st_distance_spheroid您的距离查询,将数据存储在地理列中,或将其转换为本地投影(存储时或动态,具体取决于您的需要)。

As long as you never intend to reproject/transform the data to another coordinate system, it doesn't technically matter what srid you use. However assuming you don't want to throw away that important metadata, and you do want to transform it, you will want to ensure your assigned srid matches the data, so postgis knows what to do when the time comes.

So why would you want to reproject from epsg:4269? The answer is because certain types of queries (such as distance) make no sense in this 'unprojected' world. Your units are in decimal degrees, and a straight measurement of x decimal degrees is a different real distance depending where in the planet you are.

In your example above, someone is using epsg:32661 as they believe it will give them better accuracy for the are they're working in. If your data is in a specific area of the globe, you can select a projection that's accurate for that area. If it spans the entire globe, you have to choose a projection that does 'ok' for your needs.

Now fortunately PostGIS has a few ways of making all this easier. For approx distances you can just use the st_distance_sphere function which, as you might guess, assumes the earth is a sphere. Or the more accurate st_distance_spheroid. Using these, you don't need to reproject and you will probably be fine for your distance queries except in edge cases. Newer versions of PostGIS also let you use geography columns

tl;dr - use st_distance_spheroid for your distance queries, store your data in geography columns, or transform it to a local projection (when storing, or on the fly, depending on your needs).

情场扛把子 2024-10-19 11:19:13

看看这个问题:如何你知道 shp 文件使用什么 SRID 吗?

SRID 只是一种在数据库中存储 WKT 的方法(您可能已经注意到,尽管您存储纬度/经度点,但首选存储是包含数字和大写字母的长字符串)。

SRID 或 EPSG 对于国家/州/国家/地区可能有所不同...尽管有一些非常常见的,尤其是你提到的两个。如果您需要特定信息哪个区域使用哪个 SRID,可以使用数据库来处理该信息

在您的数据库中,您有一个表 spatial_ref_sys,其中包含 SRID PostGIS 所了解的信息。

Take a look at this question: How do you know what SRID to use for a shp file?

The SRID is just a way of storing the WKT inside the database (you may have noticed that, altough you store lat/long points, the preferred storing is a long string with number and capital letters).

The SRID or EPSG can be different for the country/state/... altough there are some very common ones especially the 2 mentioned by you. If you need specific info what area uses what SRID, there is a database for handling that.

Inside your database, you have a table spatial_ref_sys that has the information on what SRID PostGIS knows about.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文