解释来自 shapefile 的 geopandas 纬度/经度数据

发布于 2025-01-19 09:31:22 字数 384 浏览 2 评论 0原文

我正在使用地理层来提取shapefile的纬度和经度坐标(而不是多边形坐标)。目前,我正在使用质心X/y方法从我的geopandas df 数据中获取坐标:

lon = data.centroid.x  
lat = data.centroid.y

这是相应的输出(对于纬度):

​如何解释这一点:

  1. 为什么值这么大?是因为我使用了错误的CRS吗?
  2. 如果我使用错误的CR,是否有一种方法可以解决此问题?我尝试了 data.crs ,但它返回null并使用 data.set_crs 似乎无法解决问题。

I am using geopandas to extract the latitude and longitude coordinates (rather than the polygon coordinates) for a shapefile. Currently, I am using the centroid x/y methods to get the coordinates from my geopandas df data:

lon = data.centroid.x  
lat = data.centroid.y

Here is the corresponding output (for latitude):

enter image description here

I have 2 questions on how to interpret this:

  1. Why are the values so large? Is it because I am using the wrong crs?
  2. If I am using the wrong crs, is there a way to fix this? I have tried data.crs but it returns null and using data.set_crs doesn't seem to fix the problem.

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

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

发布评论

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

评论(1

笑饮青盏花 2025-01-26 09:31:22

“为什么这些值这么大?是因为我使用了错误的CRS吗?”

-->因为这些坐标是平面投影,它们的值以米为单位。最常见的平面投影是 UTM,所以情况可能就是这样。您可以在此处找到有关 UTM 坐标的更多信息。

“如果我使用了错误的 CRS,有没有办法解决这个问题?我已经尝试过 data.crs,但它返回 null,并且使用 data.set_crs 似乎无法解决问题。”

-->如果您想计算距离,并且所有多边形都位于同一个 UTM 区域中,那么 UTM 坐标是一个很好的投影选择。否则,您可以使用 geopandas 方法“set_crs”和正确的 EPSG 代码,然后使用该方法“to_crs”将其转换为另一个投影。方法“.crs”返回 null,因为 geopandas 无法找到多边形的 EPSG。为了解决缺少坐标参考的问题(如果您正在处理 shapefile),请将 .prj 文件保留在 .shp 文件的同一文件夹中。否则,如果您使用其他信息源,请检查您从何处获取该数据。坐标系可能是在您下载多边形的站点上通知的。

我认为此视频也会对您有所帮助

"Why are the values so large? Is it because I am using the wrong CRS?"

--> Because these coordinates are planar projections and their values are in meters. The most common planar projection is UTM so probably it's the case. You can find more about UTM coordinates here.

"If I am using the wrong CRS, is there a way to fix this? I have tried data.crs but it returns null and using data.set_crs doesn't seem to fix the problem."

-->If you want to calculate distances, and all your polygons are in the same UTM zone then UTM coordinates are a great projection choice. Otherwise, you can use the geopandas method "set_crs" with the correct EPSG code and then use the method "to_crs" to convert it into another projection. The method ".crs" is returning null because geopandas could not find what is the EPSG of your polygons. To solve this absence of reference for your coordinates if you are dealing with a shapefile keep the .prj file in the same folder of your .shp file. Otherwise, if you are using another source of information, check where you got that data. Probably the coordinate system is informed at the site where you downloaded the polygons.

I think this video will also help you

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