Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

erase.point

Erase points


Description

Removes points intersecting a polygon feature class

Usage

erase.point(y, x, inside = TRUE)

Arguments

y

A SpatialPoints or SpatialPointsDataFrame

x

A SpatialPolygons or SpatialPolygonsDataFrame

inside

(TRUE/FALSE) Remove points inside polygon, else outside polygon

Value

A SpatialPoints or SpatialPointsDataFrame

Note

Used to erase points that intersect polygon(s). If inside=FALSE then the function results in an intersection operation where points that intersect the polygon are retained. This function effectively duplicates the ESRI ArcGIS Erase Point tool.

Author(s)

Jeffrey S. Evans <jeffrey_evans<at>tnc.org>

Examples

library(sp)
library(raster)
library(rgeos)
  data(meuse)
  coordinates(meuse) = ~x+y

# Create systematic sample and polygons
s <- spsample(x=as(extent(meuse), "SpatialPolygons"), n=1000,
              type="regular")
b <- rgeos::gBuffer(s[sample(1:length(s),5),],
                    byid = FALSE, width = 300)

# Erase points based on polygons
s.erase <- erase.point(s, b)
 
 opar <- par(no.readonly=TRUE)
 par(mfrow=c(2,2))
   plot(s, pch=20, main="original data")
   plot(b, main="erased data")
     points(s.erase, pch=20)
   plot(b, main="erased data using inside=FALSE")
     points(erase.point(s, b, inside=FALSE), pch=20)
 par(opar)

spatialEco

Spatial Analysis and Modelling Utilities

v1.3-6
GPL-3
Authors
Jeffrey S. Evans [aut, cre], Melanie A. Murphy [ctb], Karthik Ram [ctb]
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.