The GRTSmh_diffres data source is derived from GRTSmh_brick. It provides the hierarchical levels 1 to 9 of the GRTS cell addresses at the corresponding spatial resolution. The function returns one selected level, either as a SpatRaster or as an sf polygon layer (in the latter case, only levels 4 to 9 are provided). The coordinate reference system is 'BD72 / Belgian Lambert 72' (EPSG-code 31370).

read_GRTSmh_diffres(
  dir = file.path(locate_n2khab_data(), "20_processed/GRTSmh_diffres"),
  level,
  polygon = FALSE
)

Arguments

dir

The data source directory (absolute or relative). The default follows the data management advice in the vignette on data storage (run vignette("v020_datastorage")). It uses the first n2khab_data folder that is found when sequentially climbing up 0 to 10 levels in the file system hierarchy, starting from the working directory.

level

Integer in the range from 1 to 9; determines the spatial resolution. See the Details section.

polygon

Logical; determines whether a polygon layer or a SpatRaster is returned. See the Details section.

Value

Either a SpatRaster or a Simple feature collection of geometry type POLYGON.

If the package is configured to use the raster package (see n2khab_options()), a RasterLayer is returned instead of a SpatRaster.

Details

The GRTSmh_diffres data source file is a file collection (available at Zenodo), composed of nine monolayered GeoTIFF files of the INT4S datatype plus a GeoPackage with six polygon layers:

  • The polygon layers in the GeoPackage are the dissolved, polygonized versions of levels 4 to 9 of the GRTSmh_brick data source (see read_GRTSmh). This means that they provide the decimal (i.e. base 10) integer values of these higher hierarchical levels of the GRTS cell addresses of the raw data source GRTSmaster_habitats. Hence, the polygons are typically squares that correspond to the GRTS cell at the specified hierarchical level. The polygon layer is however restricted to the non-NA cells of the original GRTSmaster_habitats raster. Consequently, a part of the polygons is clipped along the Flemish border. Levels 1 to 3 are not provided for the whole of Flanders, because this would inflate the GPKG file. You can look at the source code to do such things.

  • The GeoTIFF files provide the respective levels 1 to 9 of the GRTSmh_brick data source in a raster format, at the resolution that corresponds to the GRTS cell at the specified hierarchical level. The presence of NA cells around Flanders at level 0 implies that, with decreasing resolution, the raster's extent increases and larger areas outside Flanders are covered by non-NA cells along the border.

The function returns the selected level either as an sf polygon layer or as a SpatRaster, depending on the polygon argument.

The higher-level ranking numbers (compared to the original level 0) allow spatially balanced samples at lower spatial resolution than that of 32 m, and can also be used for aggregation purposes.

The levels 1 to 9 correspond to the resolutions vector 32 * 2^(1:9) in meters:

levelresolution (m)
164
2128
3256
4512
51024
62048
74096
88192
916384

See R-code in the n2khab-preprocessing repository for the creation from the GRTSmh_brick data source.

Beware that not all GRTS ranking numbers at the specified level are provided, as the original GRTS raster has been clipped with the Flemish outer borders (i.e., not excluding the Brussels Capital Region).

See also

Other functions involved in processing the 'GRTSmaster_habitats' data source: convert_base4frac_to_dec(), convert_dec_to_base4frac(), read_GRTSmh_base4frac(), read_GRTSmh()

Examples

if (FALSE) {
# This example supposes that your working directory or a directory up to 10
# levels above has
# the 'n2khab_data' folder AND that the latest version of the
# 'GRTSmh_diffres' data source is present in the default subdirectory.
# In all other cases, this example won't work but at least you can consider
# what to do.
r <- read_GRTSmh_diffres(level = 7)
r
p <- read_GRTSmh_diffres(level = 7, polygon = TRUE)
p
}