How To Basics

The geoinformation platform of the Swiss Confederation (data.geo.admin.ch) provides access to a variety of datasets.

Access to the data is granted via their API which is a ‘metadata API’ which lists the available datasets and points towards the files (data) linked specific datasets. The structure is as follows:

Available collections

The function sg_collections() allows to retrieve all available collections.

(collections <- sg_collections())
# A tibble: 511 × 11
   id          title description license created             updated            
   <chr>       <chr> <chr>       <chr>   <dttm>              <dttm>             
 1 ch.agrosco… Dist… "The map o… CC-BY   2025-05-22 15:30:58 2026-03-04 14:03:13
 2 ch.agrosco… Amph… "Swiss-wid… propri… 2025-05-22 14:39:07 2026-05-11 20:00:02
 3 ch.agrosco… Agri… "Switzerla… propri… 2025-05-22 14:57:25 2026-03-04 14:03:14
 4 ch.agrosco… Wetn… "Das Feuch… propri… 2023-09-26 12:39:29 2026-03-04 14:03:15
 5 ch.agrosco… Focu… "The publi… propri… 2025-05-22 15:42:25 2026-03-04 14:03:16
 6 ch.agrosco… Pote… "This data… propri… 2025-08-18 13:40:42 2026-03-04 14:03:16
 7 ch.agrosco… Qual… "This data… propri… 2025-08-18 13:55:50 2026-03-04 14:03:17
 8 ch.are.agg… Citi… "The list … propri… 2021-10-13 14:38:04 2025-07-21 14:18:12
 9 ch.are.alp… Alpi… "The perim… propri… 2021-10-13 14:41:42 2026-05-11 20:00:04
10 ch.are.bel… Load… "Passenger… propri… 2021-10-13 14:44:14 2026-06-08 20:00:02
# ℹ 501 more rows
# ℹ 5 more variables: itemType <chr>, crs <int>, extent <list>,
#   data_from <dttm>, data_to <dttm>

A regex pattern can be specified to filter collections, however, in the background all collections have to be downloaded, so this does not reduce computation time.

Collection details

As an example, we are looking for all collections matching the string "erreichbarkeit-oev", a data set which provides information about accessibility by public transport.

The object returned contains a series of information:

  • id: Unique collection identifier
  • title/description: Title and short description.
  • license: Data license
  • created/updated: When the collection was created and last updated
  • itemType: Type of data
  • crs: Coordinate reference system
  • extent: Spatial extent
  • data_from/data_to: Temporal extent
(oev <- sg_collections("erreichbarkeit-oev"))
# A tibble: 1 × 11
  id           title description license created             updated            
  <chr>        <chr> <chr>       <chr>   <dttm>              <dttm>             
1 ch.are.erre… Acce… Accessibil… propri… 2021-10-13 14:50:08 2026-05-07 12:54:11
# ℹ 5 more variables: itemType <chr>, crs <int>, extent <list>,
#   data_from <date>, data_to <date>
str(oev, 2)
tibble [1 × 11] (S3: tbl_df/tbl/data.frame)
 $ id         : chr "ch.are.erreichbarkeit-oev"
 $ title      : chr "Accessibility by public transport depending on travel time and potential at destination"
 $ description: chr "Accessibility per traffic zone in public transport depending on the public transport travel times from all zone"| __truncated__
 $ license    : chr "proprietary"
 $ created    : POSIXct[1:1], format: "2021-10-13 14:50:08"
 $ updated    : POSIXct[1:1], format: "2026-05-07 12:54:11"
 $ itemType   : chr "Feature"
 $ crs        : int 2056
 $ extent     :List of 1
 $ data_from  : Date[1:1], format: "2017-06-30"
 $ data_to    : Date[1:1], format: "2017-06-30"

Items

Given the id of a specific collection sg_items() is used to retrieve the items within the collection.

(items <- sg_items(oev$id))
Simple feature collection with 1 feature and 9 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 5.96 ymin: 45.82 xmax: 10.49 ymax: 47.81
Projected CRS: CH1903+ / LV95
                  id                collection    type stac_version   datetime
1 erreichbarkeit-oev ch.are.erreichbarkeit-oev Feature        1.0.0 2017-06-30
                title             created             updated    assets
1 Accessibility by PT 2021-10-13 15:05:38 2026-05-07 12:54:11 assets: 1
                        geometry
1 POLYGON ((5.96 45.82, 5.96 ...

This collection only contains one item which itself contains one asset ($assets). The asset is a geospatial file (.gpkg).

items$assets
[1] Assets: 1
      [application/geopackage+sqlite3] erreichbarkeit-oev_2056.gpkg
str(items$assets[[1L]], 1)
'data.frame':   1 obs. of  7 variables:
 $ name         : chr "erreichbarkeit-oev_2056.gpkg"
 $ type         : chr "application/geopackage+sqlite3"
 $ href         : chr "https://data.geo.admin.ch/ch.are.erreichbarkeit-oev/erreichbarkeit-oev/erreichbarkeit-oev_2056.gpkg"
 $ created      : POSIXct, format: "2021-10-14 07:13:02"
 $ updated      : POSIXct, format: "2026-05-07 12:54:11"
 $ proj:epsg    : int 2056
 $ file:checksum: chr "122065c1fa35443202126adf067d7a5bd83aea4d4935b219b032bf41892717b45e5e"

In this case we have all the required information and could download or read the data set.

## Note: This code chunk is not executed in the documentation
library("sf")
x <- read_sf(items$assets[[1]]$href)
plot(x["OeV_Erreichb_EWAP"])