Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active May 10, 2024 15:33
Show Gist options
  • Save mdsumner/1ca063d5fdf6c644b33b920c77044c9e to your computer and use it in GitHub Desktop.
Save mdsumner/1ca063d5fdf6c644b33b920c77044c9e to your computer and use it in GitHub Desktop.
set.seed(1)

url = "https://naciscdn.org/naturalearth/10m/raster/SR_LR.zip/SR_LR.tif"
url = paste0("/vsizip/vsicurl/", url)
#url <- "/vsicurl/https://gebco2023.s3.valeria.science/gebco_2023_land_cog.tif"

n = 44000
pts = cbind(x = runif(n, -180, 180), y = runif(n, -90, 90))


## https://github.com/hypertidy/gdallocationinfo
library(gdallocationinfo)

system.time({
  e <- locationinfo(url, pts)
})


# library(terra)
# library(raster)

# raster -----------------------------------------------------------------------
# system.time({
#   r1 = raster(url)
#   e1 = extract(r1, pts)
# })
# 
# # terra ------------------------------------------------------------------------
# system.time({
#   r2 = rast(url)
#   e2 = extract(r2, pts)
# })
# 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment