library(gdalraster)
library(ximage) ## remotes::install_github("hypertidy/ximage")
dsn <- "/vsicurl/https://prd-tnm.s3.amazonaws.com/StagedProducts/Elevation/1/TIFF/USGS_Seamless_DEM_1.vrt"
## we want a grid of a local area
ex <- c(-2, 2, -1, 1) * 85000
args <- c("-te", ex[1], ex[3], ex[2], ex[4], "-ts", 1024, 0)
crs <- "+proj=laea +lon_0=-112.6 +lat_0=36.3"
tf <- tempfile(fileext = ".vrt", tmpdir = "/vsimem")
gdalraster::warp(dsn, tf, crs, cl_arg = args)
ds <- new(GDALRaster, tf)
## gdal raster has a read_ds()
dat1 <- read_ds(ds)
## now mars
dsn <- "/vsicurl/https://planetarymaps.usgs.gov/mosaic/Mars/HRSC_MOLA_Blend/Mars_HRSC_MOLA_BlendDEM_Global_200mp_v2.tif"
## we want a grid of a local area
ex <- c(-2, 2, -1, 1) * 1400000
args <- c("-te", ex[1], ex[3], ex[2], ex[4], "-ts", 1024, 0)
crs <- "+proj=laea +lon_0=-52.2 +lat_0=-8.9 +R=3396190"
tf <- tempfile(fileext = ".vrt", tmpdir = "/vsimem")
gdalraster::warp(dsn, tf, crs, cl_arg = args)
ds <- new(GDALRaster, tf)
## gdal raster has a read_ds()
dat <- read_ds(ds)
par(mfrow = c(2, 1), mar = rep(0, 4))
ximage::ximage(dat1, asp = 1)
ximage::ximage(dat, asp = 1)
bb <- attr(dat1, "gis")$bbox + c(-1e6, 1e6, -1e6, 1e6)
rect(bb[1], bb[2], bb[3], bb[4], border = "red")
Created
February 16, 2024 04:01
-
-
Save mdsumner/c904554e1db1f1e8e78c9eb36df8f9df to your computer and use it in GitHub Desktop.
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

the original purpose was me getting "xml:VRT" out of the metadata which gdalraster provides (with no file-stuff) - but then I got distracted with how cool the data is 😂