我正在尝试在r中制作地形图。第一步,下载高程数据:
ex_df <- data.frame(x=c(5.86, 7.7, 7.7, 5.86, 5.86), y=c(50.59, 50.59, 49.8, 49.8, 50.59))
crs_obj <- crs("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
elev <- get_elev_raster(ex_df, z=12, prj=crs_obj, clip = "bbox")我得到以下错误:
Error in sp::CRS(prj) :
PROJ4 argument-value pairs must begin with +: GEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]],
CS[ellipsoidal,2],
AXIS["longitude",east,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]],
AXIS["latitude",north,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]]]搜索SO给了我这个解决方案(Create topographic map in R):
# Generate a data frame of lat/long coordinates.
ex.df <- data.frame(x=seq(from=-73, to=-72.5, length.out=10),
y=seq(from=41, to=41.5, length.out=10))
# Specify projection.
prj_dd <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
# Use elevatr package to get elevation data for each point.
elev <- get_elev_raster(ex.df, prj = prj_dd, z = 10, clip = "bbox")还有..。同样的错误。很明显,prj的论点有问题,但在线搜索并不能澄清应该如何修复。有什么想法吗?
发布于 2021-06-21 00:13:12
尝试使用sf包:
library(sf)
library(magrittr)
ex.df %>%
st_as_sf(coords = c("x", "y"), crs = 4326) %>%
elevatr::get_elev_point()
Simple feature collection with 10 features and 2 fields
geometry type: POINT
dimension: XY
bbox: xmin: -73 ymin: 41 xmax: -72.5 ymax: 41.5
geographic CRS: WGS 84 (with axis order normalized for visualization)
elevation elev_units geometry
1 0.00 meters POINT (-73 41)
2 0.00 meters POINT (-72.94444 41.05556)
3 0.00 meters POINT (-72.88889 41.11111)
4 0.00 meters POINT (-72.83333 41.16667)
5 0.00 meters POINT (-72.77778 41.22222)
6 52.59 meters POINT (-72.72222 41.27778)
7 56.54 meters POINT (-72.66667 41.33333)
8 85.23 meters POINT (-72.61111 41.38889)
9 171.73 meters POINT (-72.55556 41.44444)
10 87.20 meters POINT (-72.5 41.5)发布于 2021-06-22 19:45:10
更新R和相关的包解决了这个问题。
https://stackoverflow.com/questions/68056802
复制相似问题