rasterPointCount: Calculate the number of points falling within each pixel in a...

Description Usage Arguments Value See Also Examples

Description

Given a rasterbrick and a two-column matrix of coordinates 'coords' (in the order: x, y), the function counts the number of points falling within each pixel in the rasterbrick and returns a three-column dataframe containing the x and y coordinates for each pixel and the count of occurrence points for that pixel. Pixels containing no points are assigned the value 0.

Option to include pseudo-absence points. A second two-column matrix of coordinates 'absence' (in the order: x, y)

If extract = TRUE raster values for each pixel are extracted and also returned in the dataframe.

If any coordinates for occurrence and pseudo-absence points fall within the same pixel, they are removed from the pseudo-absence dataset and a warning is issued.

Usage

1
rasterPointCount(rasterbrick, coords, absence=NULL, extract=FALSE)

Arguments

rasterbrick

The raster from which to calculate the number of points within each pixel.

coords

A two-column matrix of coordinates in the order x then y. Occurrence points.

absence

A two-column matrix of coordinates in the order x then y. Pseudo-absence points.

extract

Whether to extract and return raster values.

Value

A three-column dataframe containing x and y coordinates for each pixel and the count of occurrence points for that pixel. Pixels containing no points are assigned the value 0.

If pseudo-absence points are included, the function returns a three-column dataframe containing x and y coordinates for each pixel and the count of occurrence points for that pixel. Pixels containing pseudo-absence points are assigned the value 0. Pixels containing no points are removed.

See Also

cellFromXY

Examples

 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
29
30
31
32
33
34
35
# load a test raster
data(covariates)

# make some occurrence points
occ <- matrix(c(-5, 0,
                0, -5,
                -5, 5,
                -5, 5,
                -5, 10),
                ncol = 2,
                byrow = TRUE)

# make some pseudo-absence points
absence <- matrix(c(-6, 2,
                    -7, 5,
                    5, -4,
                    -5, 5,
                    -5, 10),
                    ncol = 2,
                    byrow = TRUE)

# get count of points for each raster pixel for occurrence data only
count_data_occ <- rasterPointCount (covariates, occ) 

# get count of point for each raster pixel for occurrence and pseudo-absence
# points
count_data <- rasterPointCount(covariates, occ, absence)

# get count of point for each raster pixel for occurrence data and extract
# raster values
count_data_occ_covs <- rasterPointCount (covariates, occ, extract=TRUE) 

# get count of point for each raster pixel for occurrence and pseudo-absence
# data and extract raster values
count_data_covs <- rasterPointCount (covariates, occ, absence, extract=TRUE) 

SEEG-Oxford/seegSDM documentation built on May 9, 2019, 11:08 a.m.