hypertidy/ceramic

ggimg to visualize cache (and obvious connotations)

mdsumner opened this issue · 1 comments

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))

  • export efficient (memoized?) functions to get zoom, tile_x, tile_y, tile_xmin/xmax/ymin/ymax
  • optionally detect target canvas and resize with vapour::vapour_read_raster (or lazyraster) as appropriate

image

yet again one for #32