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, return_sf = TRUE)

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)

return_sf

logical. If FALSE, a long-format data frame giving the coordinates of the vertices of each cell is returned. This is is considerably faster and more memory efficient than creating an sf data frame.

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 Sept. 11, 2024, 6:58 p.m.