dgcellstogrid: Return boundary coordinates for specified cells

View source: R/dggridR.R

dgcellstogridR Documentation

Return boundary coordinates for specified cells

Description

Returns the coordinates constituting the boundary of a specified set of cells. Duplicates are eliminated to reduce processing and storage requirements.

Usage

dgcellstogrid(dggs, cells, savegrid = NA)

Arguments

dggs

A dggs object from dgconstruct()

cells

The cells to get the boundaries of

savegrid

If savegrid is set to a file path, then a shapefile containing the grid is written to that path and the filename is returned. No other manipulations are done. Default: NA (do not save grid, return it)

Value

Returns an sf object. If !is.na(savegrid), returns a filename.

Examples

library(dggridR)
data(dgquakes)

#Construct a grid with cells about ~1000 miles wide
dggs          <- dgconstruct(spacing=1000,metric=FALSE)
dgquakes$cell <- dgGEO_to_SEQNUM(dggs,dgquakes$lat,dgquakes$lon)$seqnum

#Get grid cells for the earthquakes identified
grid          <- dgcellstogrid(dggs, dgquakes$cell)

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