Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created April 14, 2025 13:53
Show Gist options
  • Save mdsumner/9d43f3a638ab81afcbcdd3cea61a1a1a to your computer and use it in GitHub Desktop.
Save mdsumner/9d43f3a638ab81afcbcdd3cea61a1a1a to your computer and use it in GitHub Desktop.
files <- readr::read_csv("https://ogd.swisstopo.admin.ch/resources/ch.swisstopo.swissalti3d-fOYMuina.csv", col_names = FALSE)

head(files$X1)
[1] "https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2501-1120/swissalti3d_2019_2501-1120_0.5_2056_5728.tif"
[2] "https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2501-1121/swissalti3d_2019_2501-1121_0.5_2056_5728.tif"
[3] "https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2501-1122/swissalti3d_2019_2501-1122_0.5_2056_5728.tif"
[4] "https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2502-1120/swissalti3d_2019_2502-1120_0.5_2056_5728.tif"
[5] "https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2502-1121/swissalti3d_2019_2502-1121_0.5_2056_5728.tif"
[6] "https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2502-1122/swissalti3d_2019_2502-1122_0.5_2056_5728.tif"

## helper to open the dataset from url
fun <- function(x) new(GDALRaster, sprintf("/vsicurl/%s", x))

## see how every file name has exactly the bottom left corner of the bottom left pixel in km, 
## and presumably each is exactly 1km across (2000x2000)
fun(files$X1[1])
C++ object of class GDALRaster
 Driver : GeoTIFF (GTiff)
 DSN    : /vsicurl/https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2501-1120/swissalti3d_2019_2501-1120_0.5_2056_5728.tif
 Dim    : 2000, 2000, 1
 CRS    : CH1903+ / LV95 (EPSG:2056)
 Res    : 0.500000, 0.500000
 Bbox   : 2501000.000000, 1120000.000000, 2502000.000000, 1121000.000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment