【问题标题】:collecting elevation data - extract geolocations from a geotiff file收集高程数据 - 从 geotiff 文件中提取地理位置
【发布时间】:2020-02-19 15:36:07
【问题描述】:

我正在尝试使用 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/,目前在该部分:

“下载高程数据”

作者使用从该链接收集的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 文件过滤到仅经纬度坐标?

【问题讨论】:

    标签: r maps raster geotiff


    【解决方案1】:

    您可以查看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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-27
      • 2017-10-07
      • 2021-06-22
      • 2020-06-26
      • 1970-01-01
      • 2021-01-07
      • 1970-01-01
      相关资源
      最近更新 更多