收集高程数据 - 从 geotiff 文件中提取地理位置
collecting elevation data - extract geolocations from a geotiff file
我正在尝试使用 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/,目前在:
"Downloading Elevation Data"
作者使用USGS
从这个link收集的数据:
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
我用我的 link 替换了经纬度坐标:
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
是 U.S。数据提供者。所以我下载了以下文件:
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
文件过滤为仅经纬度坐标?
你可以看看 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")
我正在尝试使用 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/,目前在:
"Downloading Elevation Data"
作者使用USGS
从这个link收集的数据:
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
我用我的 link 替换了经纬度坐标:
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
是 U.S。数据提供者。所以我下载了以下文件:
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
文件过滤为仅经纬度坐标?
你可以看看 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")