Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active July 4, 2025 06:13
Show Gist options
  • Save mdsumner/daa6498e48ab41572efb4d391a03dac2 to your computer and use it in GitHub Desktop.
Save mdsumner/daa6498e48ab41572efb4d391a03dac2 to your computer and use it in GitHub Desktop.

https://bsky.app/profile/mdsumner.bsky.social/post/3lt4lhylxhs2v

info <- vapour::vapour_raster_info(dsn <- "/vsicurl/https://projects.pawsey.org.au/idea-gebco-tif/GEBCO_2024.tif")
## remotes::install_github("hypertidy/grout")
g <- grout::grout(info$dimension, info$extent, blocksize = info$block)
idx <- grout::tile_index(g)
options(parallelly.fork.enable = TRUE, future.rng.onMisuse = "ignore")
library(furrr); plan(multicore)
fun <- function(x) {
    ex <- unlist(x[1, c("xmin", "xmax", "ymin", "ymax")])
    dsn <- "/vsicurl/https://projects.pawsey.org.au/idea-gebco-tif/GEBCO_2024.tif"
    r <- terra::crop(terra::rast(dsn), terra::ext(ex))
    v <- terra::values(r)
    w <- which(v == 4326)
    if (length(w) < 1) return(NULL)
    terra::xyFromCell(r, w)
}
m <- future_map(split(idx, 1:nrow(idx)), fun)
plot(rast(sprintf("vrt://%s?ovr=5", sds::gebco())))
points(do.call(rbind, m), pch = 19, cex = .4, col = "hotpink")
plan(sequential)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment