Open mdsumner opened 3 years ago
Here's an example update with the new GDAL/vapour/helper features, it simplfies what we were doing above only a little, but is very generally applicable, and is independent of the other spatial packages in R:
library(raadfiles)
files <- polarview_files(type = "jpeg")
afile <- files$fullname[nrow(files)]
tarball <- raadfiles:::polarview_jpeg_tarball(afile)
library(whatarelief)
info1 <- vapour::vapour_raster_info(glue::glue("/vsitar/{tarball}/{raadfiles:::polarview_tifname(tarball)}"))
vrt <- vapour::vapour_vrt(afile, extent = info1$extent,
projection = info1$projection)
im <- imagery(source = vrt, extent = info1$extent, projection = info1$projection,
dimension = c(512, 512) * 2)
ximage::ximage(im, extent = info1$extent)
m <- do.call(cbind, maps::map(plot = F)[1:2])
lines(reproj::reproj_xy(m, info1$projstring), lwd = 5, col = "yellow")
{whatarelief} and {ximage} are two experiments for reading and visualizing, helpers on top of the GDAL and base R graphics to simplify work, they aren't finalized yet (gdalio was an earlier experiment)
Another example, get the last 21 days of images and see that we can get a quickview mosaic of them all on the same projection (we just get the extent of all of them, they are all the same projection so it's relatively easy).
library(raadfiles)
files <- polarview_files(type = "jpeg")
afile <- files$fullname[seq(nrow(files) - 20, nrow(files))]
library(whatarelief)
vrt <- character(length(afile))
exts <- matrix(0, nrow = length(vrt), ncol = 4)
for (i in seq_along(afile)) {
tarball <- raadfiles:::polarview_jpeg_tarball(afile[i])
info1 <- vapour::vapour_raster_info(glue::glue("/vsitar/{tarball}/{raadfiles:::polarview_tifname(tarball)}"))
vrt0 <- vapour::vapour_vrt(afile[i], extent = info1$extent,
projection = info1$projection)
print(info1$projstring)
exts[i, ] <- info1$extent
vrt[i] <- vrt0
}
im <- imagery(source = vrt, extent = c(range(exts[,1:2]), range(exts[,3:4])), projection = info1$projection,
dimension = c(512, 512) * 2)
ximage::ximage(im, extent = c(range(exts[,1:2]), range(exts[,3:4])), asp = 1)
m <- do.call(cbind, maps::map(plot = F)[1:2])
lines(reproj::reproj_xy(m, info1$projstring), lwd = 1, col = "yellow")
Rough workflow, functions to get the jpegs/tif-tarballs, and some code to get the tif dimensions and geotransform, convert that to an extent for the JPEG