dgshptogrid: Return boundary coordinates for cells intersecting a...

View source: R/dggridR.R

dgshptogridR Documentation

Return boundary coordinates for cells intersecting a shapefile

Description

Returns the coordinates constituting the boundary of a set of cells which intersect or are contained by a polygon (or polygons) specified in a shapefile. Note that grid cells are also generated for holes in the shapefile's polygon(s).

Note that coordinates in the shapefile must be rounded to check polygon intersections. Currently this round preserves eight decimal digits of precision.

The eighth decimal place is worth up to 1.1 mm of precision: this is good for charting the motions of tectonic plates and the movements of volcanoes. Permanent, corrected, constantly-running GPS base stations might be able to achieve this level of accuracy.

In other words: you should be just fine with this level of precision.

Usage

dgshptogrid(dggs, shpfname, cellsize = 0.1, savegrid = NA)

Arguments

dggs

A dggs object from dgconstruct()

shpfname

File name of the shapefile. Filename should end with '.shp'

cellsize

Distance, in degrees, between the sample points used to generate the grid. Small values yield long generation times while large values may omit cells.

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

## Not run: 
library(dggridR)

dggs <- dgconstruct(spacing=25, metric=FALSE, resround='nearest')
south_africa_grid <- dgshptogrid(dggs,dg_shpfname_south_africa())

## End(Not run)

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