Learn R Programming

spatialEco (version 1.3-0)

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

Examples

Run this code
# NOT RUN {
require(sp)
data(meuse)
coordinates(meuse) = ~x+y
poly <- SpatialPolygonsDataFrame(SpatialPolygons(list(Polygons(list(
            Polygon(cbind(c(180042, 180545, 180553, 180314, 179955,
            179142, 179437, 179524, 179979, 180042), c(332373, 332026,
			   331426, 330889, 330683, 331133, 331623, 332152, 332357,
            332373)))),'1'))), data.frame(row.names=c('1'), PIDS=1))

meuse.erase <- erase.point(meuse, poly)

par(mfrow=c(1,2))
  plot(poly,)
    points(meuse, pch=20)
  plot(poly)
    points(meuse.erase, pch=20)

# }

Run the code above in your browser using DataLab