【发布时间】:2023-04-05 13:33:01
【问题描述】:
如果您能帮我解决这个问题,我会非常高兴。我想geom_point df "daa_84" 到 shp 文件 "shp_5" 中。在查看有关 stackoverflow 的多个相关问题并测试他们的答案后(从“daa_84”创建一个 sp 对象并转换 UTM 坐标以将其与“shp_5”的坐标匹配),我只得到类似情节的东西。另外,我知道“某事”需要UTM区(19S)和与我的国家(32719)相关的坐标系统(WGS84)的EPSG代码哈哈。有什么想法吗?
> head(daa_84)
# A tibble: 6 x 2
utm_este utm_norte
<dbl> <dbl>
1 201787 6364077
2 244958 6247258
3 245947 6246281
4 246100 6247804
5 246358 6242918
6 246470 6332356
> head(shp_5)
Simple feature collection with 6 features and 1 field
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: -7973587 ymin: -3976507 xmax: -7838155 ymax: -3766040
projected CRS: WGS 84 / Pseudo-Mercator
Comuna geometry
1 Rinconada MULTIPOLYGON (((-7871440 -3...
2 Cabildo MULTIPOLYGON (((-7842610 -3...
3 Petorca MULTIPOLYGON (((-7873622 -3...
4 Panquehue MULTIPOLYGON (((-7874932 -3...
5 Olmué MULTIPOLYGON (((-7916865 -3...
6 Cartagena MULTIPOLYGON (((-7973501 -3...
ggplot() + geom_sf(data = shp_5, aes()) +
geom_point(data = daa_84, aes(x= "utm_este", "utm_norte"),
alpha = 0.05, size = 0.5) +
labs(x = "Latitude", y = "Longitude")+
theme_bw()
编辑
除了william3031的答案外,这段代码也有效
library(sf)
daa_84 = tribble(~utm_este, ~utm_norte,
201787, 6364077,
244958, 6247258,
245947, 6246281,
246100, 6247804,
246358, 6242918,
246470, 6332356)
daa_84 = st_as_sf(daa_84,
coords=c('utm_este', 'utm_norte'),
crs=st_crs(32719)) %>%
st_transform(st_crs(shp_5))
【问题讨论】:
标签: coordinates sf utm