dgmaxcell: Get largest cell id for a dggs

View source: R/dggridR.R

dgmaxcellR Documentation

Get largest cell id for a dggs

Description

Cells are labeled 1-N. This function returns N. This is useful if you want to choose cells from the dggs randomly.

Usage

dgmaxcell(dggs, res = NA)

Arguments

dggs

A dggs object from dgconstruct()

res

If NA, use the resolution specified by the dggs. Otherwise, override the resolution.

Value

The maximum cell id.

Examples

#Choose a set of cells randomly distributed over the Earth
library(dggridR)
dggs    <- dgconstruct(spacing=1000, metric=FALSE, resround='down')
N       <- 100                                 #Number of cells
maxcell <- dgmaxcell(dggs)                     #Get maximum cell id
cells   <- sample(1:maxcell, N, replace=FALSE) #Choose random cells
grid    <- dgcellstogrid(dggs,cells) #Get grid

dggridR documentation built on Jan. 22, 2023, 1:15 a.m.