Description Usage Arguments Details Value Author(s) References Examples
This function takes a SpatialPointsDataFrame
object and compares each point with the boundaries of each
cell in a grid (SpatialPolygonsDataFrame
from the
grd_build
function.
1 |
grd |
A |
pts |
A |
contain |
Character ( |
id_pts()
extract the number of observations per cell
for each factor. It uses parallel programing to reduce the computation
time. This function depends on parallel
, doParallel
and
foreach
packages. By defaul the number of cores for parallel
computing is two, but it is posible to extend the number of cores
by modify the body of the funtion at line cores <- 2
An object of class SpatialPolygonsDataFrame
. The data slot
contains a data.frame with a column "id" and m columns. The m
columns represent the sample intensity in each cell of the grid for
each factor.
Enrique Del Callejo Canal (edelcallejoc@gmail.com), based on implemented algortihms in web platform SPECIES (see References).
http://species.conabio.gob.mx/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | library(sp)
library(rgeos)
library(rgdal)
library(raster)
# Loading data
data(Mex0)
data(mammals)
# Generating de grid from Mex0 data
Mex0.grd<-grd_build(Mex0)
# Identification points of mammals
system.time(x.mat<-id_pts(grd = Mex0.grd, pts = mammals))
# Loading extra libraries for ggplot2
library(plyr)
library(ggplot2)
library(mapproj)
Mex0.grd_for <- fortify(Mex0.grd)
Mex0.grd_df <- plyr::join(Mex0.grd_for,
data.frame(id = rownames(x.mat@freqmatrix ), x.mat@freqmatrix, stringsAsFactors = FALSE), by="id")
ggplot(data = Mex0.grd_df, aes(x = long, y = lat, group = group, fill = Alouatta_palliata)) +
geom_polygon(colour = "gray") +
scale_fill_gradient(low = "white", high = "red") +
coord_quickmap()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.