I'm trying to make a topographic map in r. First step, download elevation data:
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")
I get the following error:
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]]]]
Searching SO gave me this solution (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")
And... same error. Clearly there is something wrong with the prj argument, but searching online is not clarifying how that should be fixed. Any ideas?
Try with
sf
package: