centroid: Returns centroid coordinates of raster cells containing...

Description Usage Arguments Details Value Examples

View source: R/centroid.R

Description

centroid The desktop version of GARP records the instance of a presence location in a grid cell, and therefore does not distinguish between multiple locations within a single cell. This function returns the centroid location of all grid cells that contain a presence location, which circumvents multiple locations. It is useful when input rasters cells are large or when sampling was unevenly clustered. This function uses the cell size and extent of user-defined raster to generate centroid coordinates of all cells that contain presence locations.

Usage

1
centroid(x, points, xy = NULL, species, output.path = NULL)

Arguments

x

an object of class raster that represents the spatial resolution and extent of raster inputted into GARP

points

a data.frame or SpatialPointsDataFrame object containing latitude and longitude values of presence locations

xy

a vector object of latitude and longitude coordinates from points when points is class data.frame. Not needed if points is a SpatialPointsDataFrame object

species

the vector of species names from the points data.frame or SpatialPointsDataFrame object

Details

x should be a raster that represents the spatial resolution and extent of all environmental layers that will be inputted into GARP. Recommended to use a raster output by rasterPrep.

Value

A SpatialPointsDataFrame object containing "Latitude", "Longitude", and "Species" vectors.

Examples

1
2
3
4
5
6
set.seed(0)
library(raster)
r   <- raster(ncols = 100, nrows = 100)
r[] <- rbinom(5, 10, 0.3)
hs  <- data.frame("Latitude" = c(-89, 72, 63, 42, 54),"Longitude" = c(-12, 13, 24, 26, 87), "Species" = rep("Homo_sapiens", 5))
centroid(x = r, points = hs, xy = cbind(hs$Latitude, hs$Longitude), species = hs$Species)

cghaase/GARPTools documentation built on Aug. 6, 2021, 6:38 a.m.