Skip to content

Instantly share code, notes, and snippets.

View mdsumner's full-sized avatar

Michael Sumner mdsumner

  • Integrated Digital East Antarctica, Australian Antarctic Division
  • Hobart, Australia
View GitHub Profile
cnts <- rnaturalearth::ne_countries()
n <- nrow(cnts)
sf::sf_use_s2(FALSE)
pfun <-function(x) {
  x <- x[1, ]
  #expecting a sf cnt
  op <- options(warn = -1)
 on.exit(options(op))

From this URL, we remove the sidebar, and full-screen screenshot to this local PNG file, then georef from the url

https://tasmap.org/#9/-42.8830/147.0026

The file read here with rast() can be read directly with this, or itis attached below.

r <- rast("/vsicurl/https://private-user-images.githubusercontent.com/4107631/479547609-2127f648-d117-457b-ba01-6b181cdd5843.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTU2MTI0NzIsIm5iZiI6MTc1NTYxMjE3MiwicGF0aCI6Ii80MTA3NjMxLzQ3OTU0NzYwOS0yMTI3ZjY0OC1kMTE3LTQ1N2ItYmEwMS02YjE4MWNkZDU4NDMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDgxOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA4MTlUMTQwMjUyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTQ0NWJmNDk0M2NhNDUzMGI3Njg3YWQ3OWZiYmExMGYzNjY4Y2E4ZjM5OTU0YTNhNTk3YmMxZGE2NTZiMmQyYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.0TjLYya2nBjCNiO9po3uq
parcels <- function(address, distance = 200) {
  parcel_dsn <- "/vsizip//vsicurl/listdata.thelist.tas.gov.au/opendata/data/LIST_PARCELS_HOBART.zip/list_parcels_hobart.shp"
  pt <- tidygeocoder::geo(address, quiet = TRUE)
  parcel_ds <- new(gdalraster::GDALVector, parcel_dsn)
  on.exit(parcel_ds$close(), add = TRUE)
  prj <- parcel_ds$getSpatialRef()
  pp <- gdalraster::transform_xy(cbind(pt$long, pt$lat), srs_to = prj, srs_from = "EPSG:4326")
  ex <- rep(pp, each = 2) + c(-1, 1, -1, 1) * distance
 sf &lt;- gdalraster::bbox_to_wkt(ex[c(1, 3, 2, 4)])

In this thread it's actually not well defined, essentially if a vertex is used twice it shouldn't be in the output. (But should we normalize on edge or vertex, or full shared boundaries?). Should islands stay in the set? (I don't think so)

With silicate, simplest case is

library(silicate)
sc <- SC(polygon)
library(dplyr)
sc$object_link_edge <- sc$object_link_edge |> 
 group_by(edge_) |&gt; 

do you need 500 slightly overlapping Zarr datasets?

src <- "/vsicurl/https://projects.pawsey.org.au/idea-gebco-tif/GEBCO_2024.tif"
src <- "https://projects.pawsey.org.au/idea-gebco-tif/GEBCO_2024.tif"
library(purrr) ## purrr CRAN
library(mirai) ## mirai CRAN
if (!file.exists(basename(src))) {
  curl::curl_download(src, basename(src))  ## curl CRAN
}
docker run --rm -ti ubuntu

apt update
apt install -y curl 
curl -fsSL https://pixi.sh/install.sh | sh
pixi init example && cd example
#pixi add pkg-config
#pixi add gdal 
## pixi add ... r r-sf r-terra ##etc note that GDAL is very recent and for terra, but not for sf (and no sign of gdalraster)
## note the %s embedded, replace with your 'AWSAccessKeyId=AKI...'
"/vsizip/{/vsicurl/https://prod-is-usgs-sb-prod-content.s3.amazonaws.com/6810c1a4d4be022940554075/Annual_NLCD_LndCov_2024_CU_C1V1.zip?%s}/Annual_NLCD_LndCov_2024_CU_C1V1.tif"

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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)