Skip to contents

Group locations by intervals of values in given tiff-file and return geometries of the groups.

Usage

gwa_group_locations(
  gwa_tif,
  gis_sf = NULL,
  by_feature = TRUE,
  ID = NULL,
  int = seq(0, 1, by = 0.1),
  aggregate_tif = 0,
  snap_to_grid = 1e-05,
  simplify = 0.001,
  buffer = 100,
  drop_crumps = units::set_units(10, "km^2"),
  verbose = T,
  plot_process = T
)

Arguments

gwa_tif

tiff-file (terra-object)

gis_sf

optional sf object (map) to crop gwa-tif

by_feature

logical, should the grouping be done for each geometry (row in sf-object), TRUE by default (recommended for large objects), if FALSE the geometries will be merged into one.

ID

character, identification column of the sf-object. If provided, geometries will be merged by IDs.

int

numeric, intervals of values for grouping locations

aggregate_tif

(optional) integer, number of pixels in tiff to aggregation towards x and y directions (see fact parameter in terra::aggregate for details). The default value is 0 (no aggregation).

snap_to_grid

(optional) numeric size of grid. If positive, geometries will be adjusted to the closest grid (see grid_size argument in s2::s2_snap_to_grid). The default value is 1e-5 in lon/lat coordinates.

simplify

numeric, tolerance, the minimum distance between nodes in units of the crs (i.e. degrees for long/lat, see ?terra::simplifyGeom for details). Default value is 0.1. To skip this step set the value to 0.

buffer

numeric. If positive, buffer will be added to every geometry. Unit is meter if gwa_tif and gis_sf has a longitude/latitude CRS, or in the units of the coordinate reference system in other cases (typically also meter, see ?terra::buffer for details). The default value is 100. Set to 0 to skip this step.

drop_crumps

logical, if TRUE, small geometries will be dropped.

verbose

logical, should the process be reported.

plot_process

logical, plot the process of creation of geometries.

Value

sf object with geometries for each group, defined by intervals.