Skip to contents

Retrieve the entire INSPIRE grid.

Unlike the feature grids retrieved from z22_data, the INSPIRE grid encompasses the entire area of Germany. You can thus use it to join with the incomplete feature grids from z22_data to create a complete dataset.

Usage

z22_grid(
  res,
  year = 2019,
  rasterize = FALSE,
  as_sf = FALSE,
  update_cache = FALSE
)

Arguments

res

Resolution of the grid. Can be "100m", "250m", "1km", "5km", "10km", or "100km".

year

Version of the grid. Can be 2015, 2017, 2018 and 2019. Defaults to the latest version.

rasterize

If TRUE and the terra package is installed, converts the attribute coordinates to a SpatRaster.

as_sf

If TRUE and the sf package is installed, converts the attribute coordinates to an sf tibble.

update_cache

By default, both functions cache attribute files for the remainder of the R session. They are downloaded to a temporary directory and - if the file to download already exists - are recovered from the cache. In other words, when rerunning the same request multiple times, the subsequent calls should be much faster. If TRUE, disables caching for this call and overwrites the currently cached attribute file (if any) with a fresh one. Defaults to FALSE, i.e. always cache.

Value

A tibble, SpatRasterDataset or sf tibble depending on the rasterize and as_sf arguments.

If a tibble is returned each category in categories is stored in a column. If a SpatRasterDataset is returned, each category is a named layer.

Details

Note the uncompressed object sizes of the output (2019 version):

  • 100 m: 38 million cells, 291 MB

  • 250 m: 6 million cells, 47 MB

  • 1 km: 384 thousand cells, 3 MB

  • 5 km: 16 thousand cells, 0.12 MB

  • 10 km: 4 thousand cells, 0.03 MB

Examples

# Get high-res grid as tibble
z22_grid("100m")
#> # A tibble: 38,171,748 × 2
#>          x       y
#>      <int>   <int>
#>  1 4334150 2684050
#>  2 4334250 2684050
#>  3 4334350 2684050
#>  4 4334450 2684050
#>  5 4334550 2684050
#>  6 4334150 2684150
#>  7 4334250 2684150
#>  8 4334350 2684150
#>  9 4334450 2684150
#> 10 4334550 2684150
#> # ℹ 38,171,738 more rows

# Get low-res grid as raster
z22_grid("1km", rasterize = TRUE)
#> class       : SpatRasterDataset 
#> subdatasets : 0