eumohp_clip: Clip EU-MOHP raster data to an arbitrary polygon

View source: R/eumohp_clip.R

eumohp_clipR Documentation

Clip EU-MOHP raster data to an arbitrary polygon

Description

Clips the EU-MOHP raster data files as downloaded from the hydroshare data hosting platform. The files must be unzipped after the download. You can not only clip the files to a spatial extent, but you can also specify a selection of the data. This function works lazily through using the stars package. This means, that clipping and plotting (using eumohp_plot()) works really fast. Whereas writing the data (using eumohp_write()) is really slow.

Usage

eumohp_clip(
  directory_input,
  countries = NULL,
  custom_sf_polygon = NULL,
  region_name_spatcov = NULL,
  hydrologic_order = 1:9,
  abbreviation_measure = c("dsd", "lp", "sd"),
  spatial_resolution = "30m",
  eumohp_version = "v013.1.0",
  buffer = NULL
)

Arguments

directory_input

A string describing a directory where all the EU-MOHP .tif files are located. The provided directory will be searched recursively for files starting with 'eumohp_' file name prefix and a .tif ending.

countries

A character vector of arbitrary length. Each element of this vector should be a name of a country that belongs to the EEA39 countries. To see a list of these countries call 'eea39_countries' in the R console. If you provide this argument, you can specify the countries that should be clipped from the EU-MOHP data set. The rnaturalearth boundaries will be used as administrative boundaries for clipping. You can only provide on the following three arguments: countries, custom_sf_polygon, region_name_spatcov.

custom_sf_polygon

A simple feature collection with a single feature of geometry type 'POLYGON'. If you have more than one feature, use summarise() to union the features. If you provide this argument, the EUHMOHP data set will be clipped using these polygons. You can only provide on the following three arguments: countries, custom_sf_polygon, region_name_spatcov.

region_name_spatcov

A character vector of arbitrary length. Each element of this vector should be a value of the placeholder region_name_spatcov according to the file naming scheme of the EU-MOHP data set. If you provide this argument, you can specify the .tif files of the EU-MOHP data set that should be clipped included in the clipped output of this function. You can only provide on the following three arguments: countries, custom_sf_polygon, region_name_spatcov.

hydrologic_order

A integer vector of arbitrary length. Via this argument you can specify the hydrologic orders that you want to obtain in the clipped result of this function. The default is all hydrologic orders (1 - 9).

abbreviation_measure

A character vector of arbitrary length, but maximum length 3. Via this argument you can specify the measures that you want to obtain in the clipped result of this function. The default is all measures (dsd', 'lp' and 'sd').

spatial_resolution

A character vector of length 1. Via this argument you can specify the spatial resolution that you want to obtain in the clipped result of this function. The default is 30m. Currently, there is only a resolution of 30m available.

eumohp_version

A character vector of length 1. Via this argument you specify the EU-MOHP version that you are using / have downloaded. The default is v013.1.0.

buffer

A numeric vector of length 1 (optionally). Via this argument you can specify a buffer in meters that should be applied to the the provided polygons / countries. If you provided the argument region_name_spatcov, this argument is irrelevant. The default is NULL.

Value

A list of stars_proxy objects with the user specified spatial extent / shape.

Examples

## Not run: 
# Specifying the spatial extent of the clipped result
# via the argument: countries
eumohp_clip(
   directory_input = "directory/to/EU-MOHPfiles/",
   countries = "germany",
   buffer = 1E4,
   hydrologic_order = 1:4,
   abbreviation_measure = c("dsd", "lp"),
   eumohp_version = "v013.1.1"
)


# Specifying the spatial extent of the clipped result
# via the argument: custom_sf_polygon
eumohp_clip(
   directory_input = "directory/to/EU-MOHPfiles/",
   custom_sf_polygon = .test_custom_sf_polygon() |> summarise(),
   buffer = 1E4,
   hydrologic_order = 1:4,
   abbreviation_measure = c("dsd", "lp"),
   eumohp_version = "v013.1.1"
)


# Specifying the spatial extent of the clipped result
# via the argument: region_name_spatcov
eumohp_clip(
   directory_input = "directory/to/EU-MOHPfiles/",
   region_name_spatcov = c("france", "turkey", "italy2"),
   hydrologic_order = 1:4,
   abbreviation_measure = c("dsd", "lp"),
   eumohp_version = "v013.1.1"
)

## End(Not run)

MxNl/eumohpclipr documentation built on April 3, 2022, 4:50 p.m.