Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created March 20, 2024 10:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdsumner/71609d49c5cd98dafa3baffac2d4e5e9 to your computer and use it in GitHub Desktop.
Save mdsumner/71609d49c5cd98dafa3baffac2d4e5e9 to your computer and use it in GitHub Desktop.
#dsn <- dsn::vrtcon(sds::gebco(), ovr = 4)
dsn <- "vrt:///vsicurl/https://gebco2023.s3.valeria.science/gebco_2023_land_cog.tif?ovr=4"

scaled.vrt <- "scaled.vrt"
system(glue::glue("gdal_translate {dsn} scaled.vrt -scale -ot Byte"))

## here I had to edit the pal.vrt to have "scaled.vrt" rather than "mem" in the source (...)
system(glue::glue("gdalattachpct.py pal scaled.vrt pal.vrt -of VRT"))

## now we have to expand the palette to RGB/A (I don't think gdal_retile needs that)
system(glue::glue("gdal_translate pal.vrt rgb.vrt -expand rgb"))

unlink("tttfiles/", recursive = T)
dir.create("tttfiles")
system(glue::glue("gdal2tiles.py rgb.vrt tttfiles --tiledriver=PNG"))

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment