Open raymondben opened 6 years ago
Just a note for future reference: the WMS endpoint can be something like http://gibs.earthdata.nasa.gov/wms/epsg3031/best/wms.cgi?SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&LAYERS=MODIS_Terra_CorrectedReflectance_TrueColor&STYLES=&FORMAT=image%2Fpng&TRANSPARENT=false&CRS=EPSG:3031&HEIGHT=1024&WIDTH=1024&BBOX=-4194304,-4194304,4194304,4194304&TIME=2018-12-01
we can do this with vapour/gdalio
library(gdalio) #remotes::install_github("hypertidy/gdalio")
sdsnames <-
vapour::vapour_sds_names("https://gibs.earthdata.nasa.gov/wms/epsg3031/best/wms.cgi?SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&LAYERS=MODIS_Terra_CorrectedReflectance_TrueColor&STYLES=&FORMAT=image%2Fpng&TRANSPARENT=false&CRS=EPSG:3031&HEIGHT=1024&WIDTH=1024&BBOX=-4194304,-4194304,4194304,4194304&TIME=2021-10-25")
source(system.file("raster_format/raster_format.codeR", package = "gdalio", mustWork = TRUE))
## choose the output structure
## 1. some other grid
template <- raster::raster(raadtools::readice())
gdalio_set_default_grid(template)
x1 <- gdalio_raster(sdsnames$subdataset[1L], bands = 1:3)
raster::plotRGB(x1)
## 2. native (there are various zoom levels)
ri <- vapour::vapour_raster_info(sdsnames$subdataset[1])
dims <- matrix(ri$overviews, nrow = 2)
gdalio_set_default_grid(list(extent = ri$extent, dimension = dims[,ncol(dims)-1], projection = ri$projection))
x2 <- gdalio_raster(sdsnames$subdataset[1L], bands = 1:3)
raster::plotRGB(x2)
## longlat
gdalio_set_default_grid(list(extent = c(-180, 180, -90, -40), dimension = c(1024, 684), projection = "OGC:CRS84"))
x3 <- gdalio_raster(sdsnames$subdataset[1L], bands = 1:3)
raster::plotRGB(x3)
Created on 2021-10-25 by the reprex package (v2.0.1)
Moved from https://github.com/AustralianAntarcticDivision/bowerbird/issues/1
See https://earthdata.nasa.gov/earth-observation-data/near-real-time/rapid-response and earthdata.nasa.gov/about/science-system-description/eosdis-components/global-imagery-browse-services-gibs