is.inside: A test to see if a point is inside a polygon

View source: R/is.inside.R

is.insideR Documentation

A test to see if a point is inside a polygon

Description

is.inside checks whether a point or a set of points is inside a polygon, e.g., borders of a country.

Usage

is.inside(x, y, verbose = FALSE, plot = FALSE)

Arguments

x

an esd-object or a list/data.frame with the elements x$x and x$y containing the coordinates.

y

A polygon in the shape of a list/data.frame with the elements x$x and x$y containing the coordinates.

verbose

TRUE prints out diagnostics for the code.

plot

TRUE provides a graphical disgnostic.

N

Number of tests with random coordinates

Value

a boolean; TRUE if the point(s) x is/are inside the polygon y.

Examples


## Not run:  
library(readINAMdata)
data("Moz")

osmoz <- !is.inside(data.frame(x=lons,y=lats),Moz)
plot(lons,lats)
points(lons[osmoz],lats[osmoz],pch=19,col='red')
points(lons[!osmoz],lats[!osmoz],pch=19,col='green')
points(lons[is.na(osmoz)],lats[is.na(osmoz)],pch=19,col='black')
lines(Moz,type='b')

## End(Not run)


metno/esd documentation built on April 29, 2024, 3:34 p.m.