未在 shapefile 上绘制点
我正在尝试用波兰的 Powiaty(县)和克拉科夫所在的点绘制一个形状文件。这是我正在使用的代码。由于某种原因,该点没有出现在图中。
这是我获得波兰 Powiaty 的 shapefile 的地方: https://www.gis-support.pl/downloads/Powiaty.zip?_ga=2.76556755.796824239.1647028537-1312541903.1646793893
library(sf)
# Load shapefile
poland_Powiaty <- st_read("~/Powiaty.shp")
### Krakow's coordinates
krakow <- data.frame(x=19.940000819941382,
y=50.06197893970872)
point <- st_as_sf(krakow, coords = c("x", "y"))
# Set the CRS of shapefile
st_crs(point) <- "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs " # assign CRS to point
plot(poland_Powiaty[2])
plot(point,col="black",pch=19, cex=3,add=T)
有谁知道如何将克拉科夫添加到地图中?
I am trying to plot a shapefile with Poland's Powiaty (counties) and a dot where Krakow is. This is the code that I'm using. For some reason, that dot is not appearing in the plot.
This is where I got the shapefile of Poland's Powiaty: https://www.gis-support.pl/downloads/Powiaty.zip?_ga=2.76556755.796824239.1647028537-1312541903.1646793893
library(sf)
# Load shapefile
poland_Powiaty <- st_read("~/Powiaty.shp")
### Krakow's coordinates
krakow <- data.frame(x=19.940000819941382,
y=50.06197893970872)
point <- st_as_sf(krakow, coords = c("x", "y"))
# Set the CRS of shapefile
st_crs(point) <- "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs " # assign CRS to point
plot(poland_Powiaty[2])
plot(point,col="black",pch=19, cex=3,add=T)
Does anyone know how I can be able to add Krakow to the map?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你已经很接近了,但 crs 似乎是问题所在。
*编辑完整代表:
由 reprex 包于 2022 年 3 月 11 日创建 (v0.3.0)
You're close, but the crs seems to be the problem.
*edited for full reprex:
Created on 2022-03-11 by the reprex package (v0.3.0)