hypertidy / ceramic

read image server tiles direct with GDAL, or download image server tiles to a local cache
https://hypertidy.github.io/ceramic/
92 stars 6 forks source link

ggimg to visualize cache (and obvious connotations) #26

Closed mdsumner closed 4 years ago

mdsumner commented 4 years ago
library(dplyr)

f <- tibble::tibble(fullname = fs::dir_ls(recurse = TRUE, 
                              ceramic::ceramic_cache(), 
              type = "file", glob = "*.jpg")) %>% 
 mutate(zoom = ceramic:::tile_zoom(fullname), 
        tile_x = ceramic:::tile_x(fullname), 
        tile_y = ceramic:::tile_y(fullname))
exts <- do.call(rbind, purrr::map(purrr::transpose(f), 
 ~ceramic:::mercator_tile_extent(.x$tile_x, .x$tile_y, .x$zoom, 256)))
f$xmin <- exts[, 1L, drop = TRUE]
f$xmax <- exts[, 2L, drop = TRUE]
f$ymin <- exts[, 3L, drop = TRUE]
f$ymax <- exts[, 4L, drop = TRUE]

files <- f %>% dplyr::filter(grepl("satellite", fullname),
                             zoom == 6)
library(ggimg)
library(ggplot2)
ggplot(files) + geom_img(aes(xmin = xmin, xmax = xmax, 
                         ymin = ymin, ymax = ymax, img = fullname))

image

mdsumner commented 4 years ago

yet again one for #32