用相同的CR绘制两个形状文件

发布于 2025-01-31 02:51:01 字数 1238 浏览 2 评论 0原文

我有两个形状文件。

Polygon:

points:https://www.dropbox.com/scl/fo/3ss0ca930jcg9jzbsmuej/h?dl=0&rlkey=vbp7kpnho7p3rdw79mtere8ry

When I read these使用SF软件包的文件,它们似乎具有相同的CRS。

polygon
Simple feature collection with 2587 features and 1 field
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 131.6679 ymin: 34.30244 xmax: 133.3907 ymax: 37.24427
Projected CRS: JGD2011 / UTM zone 53N

points
Simple feature collection with 573 features and 1 field
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 131.6875 ymin: 34.6641 xmax: 133.3849 ymax: 36.34877
Projected CRS: JGD2011 / UTM zone 53N

我试图绘制两个文件,但失败了。

plot(polygon, col = "lightgrey", border = "grey")
plot(points, pch = "x", add = TRUE)

而且,我试图手动设置相同的CR,但绘图仍然失败。

 polygon_proj = st_transform(polygon, crs = st_crs("EPSG:6690"))
 points_proj = st_transform(points, crs = st_crs("EPSG:6690"))

欢迎任何建议,非常感谢。

I have two shape files.

polygon: https://www.dropbox.com/scl/fo/79tv08fp55ebibt6asz9c/h?dl=0&rlkey=ku6dlhidxkhc2n4hhi20vpr41

points:https://www.dropbox.com/scl/fo/3ss0ca930jcg9jzbsmuej/h?dl=0&rlkey=vbp7kpnho7p3rdw79mtere8ry

When I read these files using sf package, they seem to have the same CRS.

polygon
Simple feature collection with 2587 features and 1 field
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 131.6679 ymin: 34.30244 xmax: 133.3907 ymax: 37.24427
Projected CRS: JGD2011 / UTM zone 53N

points
Simple feature collection with 573 features and 1 field
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 131.6875 ymin: 34.6641 xmax: 133.3849 ymax: 36.34877
Projected CRS: JGD2011 / UTM zone 53N

I tried to plot the two files, but it failed.

plot(polygon, col = "lightgrey", border = "grey")
plot(points, pch = "x", add = TRUE)

And, I tried to set the same CRS manually, but plotting still failed.

 polygon_proj = st_transform(polygon, crs = st_crs("EPSG:6690"))
 points_proj = st_transform(points, crs = st_crs("EPSG:6690"))

Any advices are welcome, thanks a lot in advance.

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

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

发布评论

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

评论(1

话少心凉 2025-02-07 02:51:01

“绘制失败”可能意味着当对象上调用base 绘图时,点和多边形会水平偏移。这些功能具有不同的边界框,并且在现有图中添加功能显然并不能扩展其以适合现有图的限制,从而符合偏移。

您可以通过使用另一个地图函数来检查功能的几何形状,例如{ggplot2}的geom_sf():

library(ggplot2)
library(sf)

points <- read_sf("path_to_points_shape")
polygons <- read_sf("path_to_polygon_shape")

ggplot() + 
  geom_sf(data = points) +
  geom_sf(data = polygons)

"plotting fails" probably means that points and polygon are offset horizontally when calling base plot on the objects. The features have different bounding boxes, and adding a feature to an existing plot apparently doesn't scale it to fit the existing plot's limits, hence the shift.

You can check that the features' geometries are actually OK by using another map function, e.g. geom_sf() of {ggplot2}:

library(ggplot2)
library(sf)

points <- read_sf("path_to_points_shape")
polygons <- read_sf("path_to_polygon_shape")

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