clipout_polygon: Remove polygon at a given location from a set of polygons

View source: R/tools.R

clipout_polygonR Documentation

Remove polygon at a given location from a set of polygons

Description

This functions is a helper function to be used in combination to extract_polygon(). It removes a set of polygons nested within a multipolygon sf geometry.

Usage

clipout_polygon(data, countryname_eng, lon, lat)

Arguments

data

A dataset containing at least the columns geometry and name or rne_name

countryname_eng

The name of a country in English

lon

A vector of 2 longitude coordinates defining a box containing the polygons to extract

lat

A vector of 2 latitude coordinates defining a box containing the polygons to extract

Examples

## Clipping out the polygon for French Guiana
if (requireNamespace("rnaturalearth")) {
  world <- rnaturalearth::ne_countries(scale = "medium", returnclass = "sf")
  France <- world$geometry[world$name == "France"]
  plot(France)
  France2 <- clipout_polygon(data = world,
                             countryname_eng = "France",
                             lon = c(-55, -50), lat = c(6, 2))
  plot(France2)
}


courtiol/rangeRinPA documentation built on Sept. 29, 2022, 9:54 a.m.