我正在尝试使用rayshader软件包将高程数据添加到打印中。我可以使用leaflet软件包打印要在其中查找高程数据的区域。
library(whitebox)
library(leaflet)
library(rayshader)
library(rayrender)
library(raster)
# define bounding box with longitude/latitude coordinates
bbox <- list(
p1 = list(long = -3.6525599, lat = 40.4065001),
p2 = list(long = -3.7525599, lat = 40.4965001)
)
leaflet() %>%
addTiles() %>%
addRectangles(
lng1 = bbox$p1$long, lat1 = bbox$p1$lat,
lng2 = bbox$p2$long, lat2 = bbox$p2$lat,
fillColor = "transparent"
) %>%
fitBounds(
lng1 = bbox$p1$long, lat1 = bbox$p1$lat,
lng2 = bbox$p2$long, lat2 = bbox$p2$lat,
)我正在关注这个博客:https://wcmbishop.github.io/rayshader-demo/,目前在part:
“下载高程数据”
作者使用从以下链接收集的USGS数据:
https://elevation.nationalmap.gov/arcgis/rest/services/3DEPElevation/ImageServer/exportImage?bbox=-122.522%2C37.707%2C-122.354%2C37.84&bboxSR=4326&size=600%2C480&imageSR=4326&time=&format=jpgpng&pixelType=F32&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_BilinearInterpolation&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=html我将链接中的最新长坐标替换为我的坐标:
https://elevation.nationalmap.gov/arcgis/rest/services/3DEPElevation/ImageServer/exportImage?bbox=-3.6525599%2C40.4065001%2C-3.7525599%2C40.4965001&bboxSR=4326&size=600%2C480&imageSR=4326&time=&format=jpgpng&pixelType=F32&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_BilinearInterpolation&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=html它返回一个空图像-这并不奇怪,因为USGS是一个美国数据提供商。因此,我下载了以下文件:
DTM西班牙大陆20m http://data.opendataportal.at/dataset/dtm-spain/resource/38816df0-9d50-476f-832e-0f7f5fa21771
该文件是2.4 GB的大小,是一个为整个西班牙的文件,但我只想要我的经纬点边界的高程数据。
rgdal::GDALinfo("DTM Spain_Mainland (2019) 20m.tif")
rows 48394
columns 58187
bands 1
lower left origin.x -23380
lower left origin.y 3901190
res.x 20
res.y 20
ysign -1
oblique.x 0
oblique.y 0
driver GTiff
projection +proj=utm +zone=30 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m
+no_defs
file DTM Spain_Mainland (2019) 20m.tif
apparent band summary:
GDType hasNoDataValue NoDataValue blockSize1 blockSize2
1 Float32 TRUE -32767 1 58187
apparent band statistics:
Bmin Bmax Bmean Bsd
1 -4294967295 4294967295 NA NA
Metadata:
AREA_OR_POINT=Point 我的问题是,如何获取bbox中经度和经度位置的geotiff,或者如何将当前DTM Spain_Mainland (2019) 20m.tif文件过滤到经度和经度坐标?
发布于 2020-02-20 00:48:23
您可以查看elevatr包,它将为您提供所需的栅格:
library(elevatr)
library(raster)
bbox2 <- data.frame(x = c(-3.6525599, -3.7525599), y = c(40.4065001, 40.4965001))
elev <- get_elev_raster(bbox2, z = 13, clip = "bbox",
prj = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")

https://stackoverflow.com/questions/60303913
复制相似问题