我在CSV中有一系列来自墨西哥的纬度和经度点,我正在将其转换为sf
对象.我用http://projfinder.com/识别出了CRS.
library(sf)
library(spData)
library(tibble)
# basemap
mx = world %>% filter(iso_a2 == 'MX')
# cast to WGS84
mx = st_transform(mx, crs='EPSG:4326')
# mypoints
mypoints = tibble(
latitude = c(19.46762, 32.63224, 18.94691, 19.28556, 18.92243),
longitude = c(-98.14863, -115.5587, -103.9721, -99.13365, -99.22217)
)
mypoints_geo = st_as_sf(mypoints, coords = c("longitude", "latitude"), crs = 'EPSG:4326')
# plot
plot(mx['iso_a2'], axes=T)
plot(mypoints_geo, pch = 3, col = 'red', add=T)
正如您在第一个图像中看到的,这些点并不位于墨西哥;事实上,它们似乎甚至不位于经度/经度值所在的位置.我附上了另一张图片,来self 在geopandas
中做的另一种实现,效果很好.我需要如何修改R实现才能获得期望的结果?
我试过了:
- 更改初始CRS并转换为WGS 84
- 执行情况
- 使用在线工具搜索点位置
- 或者用
ggplot2
实现绘图.
预期的结果是从上面的Geopandas实现图像中得到的.