intersect_rgeos: Creating the Intersection of Two Spatial Polygons Data Frames

View source: R/spatial_manipulation.R

intersect_rgeosR Documentation

Creating the Intersection of Two Spatial Polygons Data Frames

Description

Produce a spatial polygons data frame of the intersection of two spatial polygons data frames, inheriting all the variables from each. In the case of duplicate variables between the two, those in polygons2@data will have a "2" appended to differentiate them. This uses rgeos::ginstersect and assumes that the row names in both polygons1 and polygons2 DO NOT HAVE SPACES.

Usage

intersect_rgeos(
  polygons1,
  polygons2,
  keep_outer = FALSE,
  projection = NULL,
  makevalid = TRUE,
  force = FALSE,
  verbose = FALSE,
  scale = 1e+05
)

Arguments

polygons1

Spatial polygons data frame. One of the set of polygons to intersect. If crs is NULL the projection from polygons1@proj4string will be used for the output.

polygons2

Spatial polygons data frame. One of the set of polygons to intersect.

keep_outer

Logical. If TRUE then the non-intersecting portions of polygons1 and polygons2 will be kept as well.

projection

Optional sp::CRS() call. Used to reproject both polygons1 and polygons2 using sp::spTransform() If NULL then the projection from polygons1@proj4string will be used. Defaults to NULL.

verbose

Logical. If TRUE then additional informative messages will be produced as the function runs. Defaults to FALSE.

scale

Numeric. A value to be passed to rgeos::setScale() to use for the steps of this function. It will be returned to the previous value before the function returns its output. Defaults to 1e5 (precision to five decimal places).

Value

A spatial polygons data frame consisting of the unique intersections of polygons1 and polygons2 with all the variables from both in the projection of either projection or polygons1. If there were variable names that occurred in both, those from polygons2 will have a "2" appended.


nstauffer/aim.analysis documentation built on Nov. 2, 2023, 12:52 a.m.