locatePolygonPoints: Point to Polygon Locator

Description Usage Arguments Examples

View source: R/PairsOfBirdSpeciesNicheOverlap_3ormoreSpp.R

Description

This function takes a two polygons and a list of points and determines whether the points fall within the polygons, then adds a column for each polygon's name with a boolean of whether the point overlaps.

Usage

1
2
3
locatePolygonPoints(test_points, polygonA, polygonB,
  crs = "+proj=longlat +ellps=WGS84", setcoord = TRUE, nameA = "A",
  nameB = "B")

Arguments

test_points

The points to check where they fall

polygonA

The first polygon

polygonB

The second polygon

crs

A coordinate reference system to assign to the polygons and the test points if setcoord = TRUE

setcoord

Whether to set a coordinate reference system to the points and polygons

nameA

The (subspecies) name associated with the first polygon

nameB

The (subspecies) name associated with the second polygon

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
listFromSubspeciesOcc = subspeciesOccQuery(spp="Cardinalis sinuatus",
        subsppList=c("sinuatus","peninsulae","fulvescens"),pointLimit=100,dbToQuery="gbif")
labeledLoc = labelSubspecies(subsppOccList=listFromSubspeciesOcc)
locs = labeledLoc[labeledLoc$subspecies=="sinuatus",]
locs_sin = labeledLoc[labeledLoc$subspecies=="sinuatus",]
locs_ful = labeledLoc[labeledLoc$subspecies=="fulvescens",]
dens_sin = subspeciesDensityMap(localities=locs_sin,quantile=0.95,
        xmin=-125,xmax=-60,ymin=10,ymax=50)
dens_ful = subspeciesDensityMap(localities=locs_ful,quantile=0.95,
        xmin=-125,xmax=-60,ymin=10,ymax=50)
densPol_sin = densityMapToPolygons(densityMap=dens_sin)
densPol_ful = densityMapToPolygons(densityMap=dens_ful)
polyLocations = labeledLoc
polyLocations = locatePolygonPoints(test_points=polyLocations,polygonA=densPol_sin,
        polygonB=densPol_ful,crs="+proj=longlat +ellps=WGS84",setcoord = TRUE,nameA="sinuatus",nameB="fulvescens")

kaiyaprovost/subsppLabelR documentation built on Nov. 20, 2018, 9:28 p.m.