countPoints {enmSdmX}R Documentation

Number of points in a "spatial points" object

Description

Returns the number of points in a sf or SpatVector object. This is typically done using either length(x) or nrow(x), depending on whether the object in question has rows or not. This function helps in ambiguous cases, so users need not care if nrow or length is needed.

Usage

countPoints(x, byFeature = FALSE)

Arguments

x

Object of class sf or SpatVector

byFeature

If FALSE, return number of points for all features combined. If TRUE, report number of points per feature.

Value

Numeric.

Examples


library(sf)

# lemur occurrence data
data(lemurs)
wgs84 <- getCRS('WGS84')
occs <- lemurs[lemurs$species == 'Eulemur fulvus', ]
occs <- sf::st_as_sf(occs, coords=c('longitude', 'latitude'), crs=wgs84)

countPoints(occs)


[Package enmSdmX version 1.1.6 Index]