nh_group: Group spatial features using a defined separation distance

View source: R/nh_group.R

nh_groupR Documentation

Group spatial features using a defined separation distance

Description

Input features are allocated into new groups depending on whether they lie within the separation distance of another input feature.

Usage

nh_group(spf, sep.dist = 0, union = FALSE)

Arguments

spf

input spatial features (sp or sf spatial object)

sep.dist

separation distance with which to define groups (see description)

union

whether to union output groups into multi-features

Details

The grouping is done by input ID, so multi-features are considered one input feature (they will not be be ungrouped).

The separation distance sep.dist is numeric and in the units of spf's coordinate system, unless the coordinate system uses latitude/longitude as the unit (e.g. WGS 84). In these cases, geodesic distances will be used and sep.dist should be specified in meters.

A column 'group' will be added to the output features. Specifying union = TRUE will output one (multi)feature per group, meaning original attributes will be discarded - only 'group' and 'count' (the number of original features in the group) will be returned. This feature requires the package dplyr to be installed.

Value

sp or sf object (same as input)

Author(s)

David Bucklin

Examples

## Not run: 
spf <- rgdal::readOGR("ambymabe/polygon_data", "ambymabe")
spg <- nh_group(spf, 1000)

## End(Not run)

VANatHeritage/nhSDM documentation built on Feb. 1, 2024, 6:39 a.m.