| Type: | Package |
| Title: | Discrete Global Grids |
| Version: | 3.1.0 |
| Date: | 2024-07-17 |
| Author: | Richard Barnes [aut], Kevin Sahr [aut, cph], Gerald Evenden [cph], Angus Johnson [cph], Frank Warmerdam [cph], Even Rouault [cph], Lian Song [ctb], Sebastian Krantz [ctb, cre] |
| Maintainer: | Sebastian Krantz <sebastian.krantz@graduateinstitute.ch> |
| NeedsCompilation: | yes |
| Depends: | R (≥ 3.4.0) |
| Imports: | Rcpp (≥ 0.12.12), collapse (≥ 1.8.0), sf (≥ 1.0), s2 (≥1.1) |
| LinkingTo: | Rcpp |
| RcppModules: | dgfuncs, gridgens, gridstats |
| Suggests: | ggplot2, knitr, rmarkdown, dplyr, maps, R.rsp, testthat |
| License: | AGPL (≥ 3) |
| Description: | Spatial analyses involving binning require that every bin have the same area, but this is impossible using a rectangular grid laid over the Earth or over any projection of the Earth. Discrete global grids use hexagons, triangles, and diamonds to overcome this issue, overlaying the Earth with equally-sized bins. This package provides utilities for working with discrete global grids, along with utilities to aid in plotting such data. |
| URL: | https://github.com/r-barnes/dggridR/ |
| BugReports: | https://github.com/r-barnes/dggridR/ |
| RoxygenNote: | 7.2.3 |
| Encoding: | UTF-8 |
| VignetteBuilder: | knitr, R.rsp |
| Language: | en-US |
| Packaged: | 2024-07-17 21:34:32 UTC; sebastiankrantz |
| Repository: | CRAN |
| Date/Publication: | 2024-07-26 06:20:02 UTC |
Convert from GEO to GEO
Description
Uses a discrete global grid system to convert between GEOand GEO (see vignette for details)
Usage
dgGEO_to_GEO(dggs, in_lon_deg, in_lat_deg)Arguments
dggs | A dggs object from dgconstruct() |
in_lon_deg | Vector of longitude, in degrees |
in_lat_deg | Vector of latitude, in degrees |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgGEO_to_GEO(dggs, in_lon_deg, in_lat_deg)## End(Not run)Convert from GEO to PLANE
Description
Uses a discrete global grid system to convert between GEOand PLANE (see vignette for details)
Usage
dgGEO_to_PLANE(dggs, in_lon_deg, in_lat_deg)Arguments
dggs | A dggs object from dgconstruct() |
in_lon_deg | Vector of longitude, in degrees |
in_lat_deg | Vector of latitude, in degrees |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgGEO_to_PLANE(dggs, in_lon_deg, in_lat_deg)## End(Not run)Convert from GEO to PROJTRI
Description
Uses a discrete global grid system to convert between GEOand PROJTRI (see vignette for details)
Usage
dgGEO_to_PROJTRI(dggs, in_lon_deg, in_lat_deg)Arguments
dggs | A dggs object from dgconstruct() |
in_lon_deg | Vector of longitude, in degrees |
in_lat_deg | Vector of latitude, in degrees |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgGEO_to_PROJTRI(dggs, in_lon_deg, in_lat_deg)## End(Not run)Convert from GEO to Q2DD
Description
Uses a discrete global grid system to convert between GEOand Q2DD (see vignette for details)
Usage
dgGEO_to_Q2DD(dggs, in_lon_deg, in_lat_deg)Arguments
dggs | A dggs object from dgconstruct() |
in_lon_deg | Vector of longitude, in degrees |
in_lat_deg | Vector of latitude, in degrees |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgGEO_to_Q2DD(dggs, in_lon_deg, in_lat_deg)## End(Not run)Convert from GEO to Q2DI
Description
Uses a discrete global grid system to convert between GEOand Q2DI (see vignette for details)
Usage
dgGEO_to_Q2DI(dggs, in_lon_deg, in_lat_deg)Arguments
dggs | A dggs object from dgconstruct() |
in_lon_deg | Vector of longitude, in degrees |
in_lat_deg | Vector of latitude, in degrees |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgGEO_to_Q2DI(dggs, in_lon_deg, in_lat_deg)## End(Not run)Convert from GEO to SEQNUM
Description
Uses a discrete global grid system to convert between GEOand SEQNUM (see vignette for details)
Usage
dgGEO_to_SEQNUM(dggs, in_lon_deg, in_lat_deg)Arguments
dggs | A dggs object from dgconstruct() |
in_lon_deg | Vector of longitude, in degrees |
in_lat_deg | Vector of latitude, in degrees |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgGEO_to_SEQNUM(dggs, in_lon_deg, in_lat_deg)## End(Not run)Convert from PROJTRI to GEO
Description
Uses a discrete global grid system to convert between PROJTRIand GEO (see vignette for details)
Usage
dgPROJTRI_to_GEO(dggs, in_tnum, in_tx, in_ty)Arguments
dggs | A dggs object from dgconstruct() |
in_tnum | Vector of triangle numbers |
in_tx | Vector of triangle x values |
in_ty | Vector of triangle y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgPROJTRI_to_GEO(dggs, in_tnum, in_tx, in_ty)## End(Not run)Convert from PROJTRI to PLANE
Description
Uses a discrete global grid system to convert between PROJTRIand PLANE (see vignette for details)
Usage
dgPROJTRI_to_PLANE(dggs, in_tnum, in_tx, in_ty)Arguments
dggs | A dggs object from dgconstruct() |
in_tnum | Vector of triangle numbers |
in_tx | Vector of triangle x values |
in_ty | Vector of triangle y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgPROJTRI_to_PLANE(dggs, in_tnum, in_tx, in_ty)## End(Not run)Convert from PROJTRI to PROJTRI
Description
Uses a discrete global grid system to convert between PROJTRIand PROJTRI (see vignette for details)
Usage
dgPROJTRI_to_PROJTRI(dggs, in_tnum, in_tx, in_ty)Arguments
dggs | A dggs object from dgconstruct() |
in_tnum | Vector of triangle numbers |
in_tx | Vector of triangle x values |
in_ty | Vector of triangle y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgPROJTRI_to_PROJTRI(dggs, in_tnum, in_tx, in_ty)## End(Not run)Convert from PROJTRI to Q2DD
Description
Uses a discrete global grid system to convert between PROJTRIand Q2DD (see vignette for details)
Usage
dgPROJTRI_to_Q2DD(dggs, in_tnum, in_tx, in_ty)Arguments
dggs | A dggs object from dgconstruct() |
in_tnum | Vector of triangle numbers |
in_tx | Vector of triangle x values |
in_ty | Vector of triangle y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgPROJTRI_to_Q2DD(dggs, in_tnum, in_tx, in_ty)## End(Not run)Convert from PROJTRI to Q2DI
Description
Uses a discrete global grid system to convert between PROJTRIand Q2DI (see vignette for details)
Usage
dgPROJTRI_to_Q2DI(dggs, in_tnum, in_tx, in_ty)Arguments
dggs | A dggs object from dgconstruct() |
in_tnum | Vector of triangle numbers |
in_tx | Vector of triangle x values |
in_ty | Vector of triangle y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgPROJTRI_to_Q2DI(dggs, in_tnum, in_tx, in_ty)## End(Not run)Convert from PROJTRI to SEQNUM
Description
Uses a discrete global grid system to convert between PROJTRIand SEQNUM (see vignette for details)
Usage
dgPROJTRI_to_SEQNUM(dggs, in_tnum, in_tx, in_ty)Arguments
dggs | A dggs object from dgconstruct() |
in_tnum | Vector of triangle numbers |
in_tx | Vector of triangle x values |
in_ty | Vector of triangle y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgPROJTRI_to_SEQNUM(dggs, in_tnum, in_tx, in_ty)## End(Not run)Convert from Q2DD to GEO
Description
Uses a discrete global grid system to convert between Q2DDand GEO (see vignette for details)
Usage
dgQ2DD_to_GEO(dggs, in_quad, in_qx, in_qy)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_qx | Vector of quadrant x values |
in_qy | Vector of quadrant y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DD_to_GEO(dggs, in_quad, in_qx, in_qy)## End(Not run)Convert from Q2DD to PLANE
Description
Uses a discrete global grid system to convert between Q2DDand PLANE (see vignette for details)
Usage
dgQ2DD_to_PLANE(dggs, in_quad, in_qx, in_qy)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_qx | Vector of quadrant x values |
in_qy | Vector of quadrant y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DD_to_PLANE(dggs, in_quad, in_qx, in_qy)## End(Not run)Convert from Q2DD to PROJTRI
Description
Uses a discrete global grid system to convert between Q2DDand PROJTRI (see vignette for details)
Usage
dgQ2DD_to_PROJTRI(dggs, in_quad, in_qx, in_qy)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_qx | Vector of quadrant x values |
in_qy | Vector of quadrant y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DD_to_PROJTRI(dggs, in_quad, in_qx, in_qy)## End(Not run)Convert from Q2DD to Q2DD
Description
Uses a discrete global grid system to convert between Q2DDand Q2DD (see vignette for details)
Usage
dgQ2DD_to_Q2DD(dggs, in_quad, in_qx, in_qy)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_qx | Vector of quadrant x values |
in_qy | Vector of quadrant y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DD_to_Q2DD(dggs, in_quad, in_qx, in_qy)## End(Not run)Convert from Q2DD to Q2DI
Description
Uses a discrete global grid system to convert between Q2DDand Q2DI (see vignette for details)
Usage
dgQ2DD_to_Q2DI(dggs, in_quad, in_qx, in_qy)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_qx | Vector of quadrant x values |
in_qy | Vector of quadrant y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DD_to_Q2DI(dggs, in_quad, in_qx, in_qy)## End(Not run)Convert from Q2DD to SEQNUM
Description
Uses a discrete global grid system to convert between Q2DDand SEQNUM (see vignette for details)
Usage
dgQ2DD_to_SEQNUM(dggs, in_quad, in_qx, in_qy)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_qx | Vector of quadrant x values |
in_qy | Vector of quadrant y values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DD_to_SEQNUM(dggs, in_quad, in_qx, in_qy)## End(Not run)Convert from Q2DI to GEO
Description
Uses a discrete global grid system to convert between Q2DIand GEO (see vignette for details)
Usage
dgQ2DI_to_GEO(dggs, in_quad, in_i, in_j)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_i | Vector of quadrant i values |
in_j | Vector of quadrant j values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DI_to_GEO(dggs, in_quad, in_i, in_j)## End(Not run)Convert from Q2DI to PLANE
Description
Uses a discrete global grid system to convert between Q2DIand PLANE (see vignette for details)
Usage
dgQ2DI_to_PLANE(dggs, in_quad, in_i, in_j)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_i | Vector of quadrant i values |
in_j | Vector of quadrant j values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DI_to_PLANE(dggs, in_quad, in_i, in_j)## End(Not run)Convert from Q2DI to PROJTRI
Description
Uses a discrete global grid system to convert between Q2DIand PROJTRI (see vignette for details)
Usage
dgQ2DI_to_PROJTRI(dggs, in_quad, in_i, in_j)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_i | Vector of quadrant i values |
in_j | Vector of quadrant j values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DI_to_PROJTRI(dggs, in_quad, in_i, in_j)## End(Not run)Convert from Q2DI to Q2DD
Description
Uses a discrete global grid system to convert between Q2DIand Q2DD (see vignette for details)
Usage
dgQ2DI_to_Q2DD(dggs, in_quad, in_i, in_j)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_i | Vector of quadrant i values |
in_j | Vector of quadrant j values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DI_to_Q2DD(dggs, in_quad, in_i, in_j)## End(Not run)Convert from Q2DI to Q2DI
Description
Uses a discrete global grid system to convert between Q2DIand Q2DI (see vignette for details)
Usage
dgQ2DI_to_Q2DI(dggs, in_quad, in_i, in_j)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_i | Vector of quadrant i values |
in_j | Vector of quadrant j values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DI_to_Q2DI(dggs, in_quad, in_i, in_j)## End(Not run)Convert from Q2DI to SEQNUM
Description
Uses a discrete global grid system to convert between Q2DIand SEQNUM (see vignette for details)
Usage
dgQ2DI_to_SEQNUM(dggs, in_quad, in_i, in_j)Arguments
dggs | A dggs object from dgconstruct() |
in_quad | Vector of quad numbers |
in_i | Vector of quadrant i values |
in_j | Vector of quadrant j values |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgQ2DI_to_SEQNUM(dggs, in_quad, in_i, in_j)## End(Not run)Convert from SEQNUM to GEO
Description
Uses a discrete global grid system to convert between SEQNUMand GEO (see vignette for details)
Usage
dgSEQNUM_to_GEO(dggs, in_seqnum)Arguments
dggs | A dggs object from dgconstruct() |
in_seqnum | Globally unique number identifying the surface polygon |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgSEQNUM_to_GEO(dggs, in_seqnum)## End(Not run)Convert from SEQNUM to PLANE
Description
Uses a discrete global grid system to convert between SEQNUMand PLANE (see vignette for details)
Usage
dgSEQNUM_to_PLANE(dggs, in_seqnum)Arguments
dggs | A dggs object from dgconstruct() |
in_seqnum | Globally unique number identifying the surface polygon |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgSEQNUM_to_PLANE(dggs, in_seqnum)## End(Not run)Convert from SEQNUM to PROJTRI
Description
Uses a discrete global grid system to convert between SEQNUMand PROJTRI (see vignette for details)
Usage
dgSEQNUM_to_PROJTRI(dggs, in_seqnum)Arguments
dggs | A dggs object from dgconstruct() |
in_seqnum | Globally unique number identifying the surface polygon |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgSEQNUM_to_PROJTRI(dggs, in_seqnum)## End(Not run)Convert from SEQNUM to Q2DD
Description
Uses a discrete global grid system to convert between SEQNUMand Q2DD (see vignette for details)
Usage
dgSEQNUM_to_Q2DD(dggs, in_seqnum)Arguments
dggs | A dggs object from dgconstruct() |
in_seqnum | Globally unique number identifying the surface polygon |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgSEQNUM_to_Q2DD(dggs, in_seqnum)## End(Not run)Convert from SEQNUM to Q2DI
Description
Uses a discrete global grid system to convert between SEQNUMand Q2DI (see vignette for details)
Usage
dgSEQNUM_to_Q2DI(dggs, in_seqnum)Arguments
dggs | A dggs object from dgconstruct() |
in_seqnum | Globally unique number identifying the surface polygon |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgSEQNUM_to_Q2DI(dggs, in_seqnum)## End(Not run)Convert from SEQNUM to SEQNUM
Description
Uses a discrete global grid system to convert between SEQNUMand SEQNUM (see vignette for details)
Usage
dgSEQNUM_to_SEQNUM(dggs, in_seqnum)Arguments
dggs | A dggs object from dgconstruct() |
in_seqnum | Globally unique number identifying the surface polygon |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
## Not run: library(dggridR)dggs <- dgconstruct(res=20)dgSEQNUM_to_SEQNUM(dggs, in_seqnum)## End(Not run)Determine an appropriate grid resolution based on input data.
Description
This is a generic function that is used to determine an appropriateresolution given an area, cell spacing, or correlated length scale.It does so by extracting the appropriate length/area column andsearching it for a value close to the input.
Usage
dg_closest_res( dggs, col, val, round = "nearest", show_info = TRUE, metric = TRUE)Arguments
dggs | A dggs object from dgconstruct() |
col | Column in which to search for a close value. Should be:area_km, spacing_km, or cls_km. |
val | The value to search for |
round | What direction to search in. Must be nearest, up, or down. |
show_info | Print the area, spacing, and CLS of the chosen resolution. |
metric | Whether input and output should be in metric (TRUE) orimperial (FALSE) |
Value
A number representing the grid resolution
Examples
library(dggridR)dggs <- dgconstruct(res=20)res <- dg_closest_res(dggs,'area_km',1)dggs <- dgsetres(dggs,res)Determine resolution based on desired area
Description
Determine an appropriate grid resolution based on a desiredcell area.
Usage
dg_closest_res_to_area( dggs, area, round = "nearest", show_info = TRUE, metric = TRUE)Arguments
dggs | A dggs object from dgconstruct() |
area | The desired area of the grid's cells |
round | What direction to search in. Must be nearest, up, or down. |
show_info | Print the area, spacing, and CLS of the chosen resolution. |
metric | Whether input and output should be in metric (TRUE) orimperial (FALSE) |
Value
A number representing the grid resolution
Examples
library(dggridR)dggs <- dgconstruct(res=20)res <- dg_closest_res_to_area(dggs,1)dggs <- dgsetres(dggs,res)Determine an appropriate grid resolution based on a desiredcharacteristic length scale of the cells.
Description
The characteristic length scale (CLS) is the diameter of a sphericalcap of the same area as a cell of the specified resolution.
Usage
dg_closest_res_to_cls( dggs, cls, round = "nearest", show_info = TRUE, metric = TRUE)Arguments
dggs | A dggs object from dgconstruct() |
cls | The desired CLS of the cells. |
round | What direction to search in. Must be nearest, up, or down. |
show_info | Print the area, spacing, and CLS of the chosen resolution. |
metric | Whether input and output should be in metric (TRUE) orimperial (FALSE) |
Value
A number representing the grid resolution
Examples
library(dggridR)dggs <- dgconstruct(res=20)res <- dg_closest_res_to_cls(dggs,1)dggs <- dgsetres(dggs,res)Determine grid resolution from desired spacing.
Description
Determine an appropriate grid resolution based on a desiredspacing between the center of adjacent cells.
Usage
dg_closest_res_to_spacing( dggs, spacing, round = "nearest", show_info = TRUE, metric = TRUE)Arguments
dggs | A dggs object from dgconstruct() |
spacing | The desired spacing between the center of adjacent cells |
round | What direction to search in. Must be nearest, up, or down. |
show_info | Print the area, spacing, and CLS of the chosen resolution. |
metric | Whether input and output should be in metric (TRUE) orimperial (FALSE) |
Value
A number representing the grid resolution
Examples
library(dggridR)dggs <- dgconstruct(res=20)res <- dg_closest_res_to_spacing(dggs,1)dggs <- dgsetres(dggs,res)Control global aspects of the dggridR package
Description
This environment is used to control global features of the dggridRpackage. At the moment the only option is 'dg_debug' which, when setto TRUE provides extensive outputs useful for tracking down bugs.
Usage
dg_envFormat
An object of classenvironment of length 1.
Load a KML file
Description
Convert data from internal dggrid functions into somethinguseful: an sp object or a data frame
Usage
dg_process_polydata(polydata)Arguments
polydata | Polygons generated by dggrid. These will be converted. |
Value
Returns an sf object.
National border of South Africa
Description
This variable points to a shapefile containing the national borderof South Africa
Usage
dg_shpfname_south_africa()Value
A filename of a shapefile containing the national border of South Africa
Return boundary coordinates for specified cells
Description
Returns the coordinates constituting the boundary of aspecified set of cells. Duplicates are eliminated to reduceprocessing 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 shapefilecontaining the grid is written to that path and the filenameis returned. No other manipulations are done.Default: NA (do not save grid, return it) |
return_sf | logical. If |
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 widedggs <- dgconstruct(spacing=1000,metric=FALSE)dgquakes$cell <- dgGEO_to_SEQNUM(dggs,dgquakes$lat,dgquakes$lon)$seqnum#Get grid cells for the earthquakes identifiedgrid <- dgcellstogrid(dggs, dgquakes$cell)Construct a discrete global grid system (dggs) object
Description
Construct a discrete global grid system (dggs) object
Usage
dgconstruct( projection = "ISEA", aperture = 3, topology = "HEXAGON", res = NA, precision = 7, area = NA, spacing = NA, cls = NA, resround = "nearest", metric = TRUE, show_info = TRUE, azimuth_deg = 0, pole_lat_deg = 58.28252559, pole_lon_deg = 11.25)Arguments
projection | Type of grid to use. Options are: ISEA and FULLER.Default: ISEA3H |
aperture | How finely subsequent resolution levels divide the grid.Options are: 3, 4. Not all options work with allprojections and topologies.Default: 3 |
topology | Shape of cell. Options are: HEXAGON, DIAMOND, TRIANGLE.Default: HEXAGON |
res | Resolution. Must be in the range [0,30]. Larger values representfiner resolutions. Appropriate resolutions can be found withdg_closest_res_to_area(), dg_closest_res_to_spacing(), anddg_closest_res_to_cls(). Default is 9, which corresponds to acell area of ~2600 sq km and a cell spacing of ~50 km.Only one of res, area, length, or cls should be used. |
precision | Round output to this number of decimal places. Must be inthe range [0,30]. Default: 7. |
area | The desired area of the grid's cells.Only one of res, area, length, or cls should be used. |
spacing | The desired spacing between the center of adjacent cells.Only one of res, area, length, or cls should be used. |
cls | The desired CLS of the cells.Only one of res, area, length, or cls should be used. |
resround | What direction to search in. Must be nearest, up, or down. |
metric | Whether input and output should be in metric (TRUE) orimperial (FALSE) |
show_info | Print the area, spacing, and CLS of the chosen resolution. |
azimuth_deg | Rotation in degrees of grid about its pole, value in [0,360].Default=0. |
pole_lat_deg | Latitude in degrees of the pole, value in [-90,90].Default=58.28252559. |
pole_lon_deg | Longitude in degrees of the pole, value in [-180,180].Default=11.25. |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
library(dggridR)dggs <- dgconstruct(res=20)dggs <- dgconstruct(area=5,metric=FALSE)Return the coordinates constituting the boundary of cells for theentire Earth
Description
Note: If you have a high-resolution grid this may take avery long time to execute.
Usage
dgearthgrid(dggs, savegrid = NA, return_sf = TRUE)Arguments
dggs | A dggs object from dgconstruct(). |
savegrid | If savegrid is set to a file path, then a shapefilecontaining the grid is written to that path and the filenameis returned. No other manipulations are done.Default: NA (do not save grid, return it) |
return_sf | logical. If |
Value
Returns an sf object.If!is.na(savegrid), returns a filename.
Examples
library(dggridR)dggs <- dgconstruct(res=20)res <- dg_closest_res_to_spacing(dggs,spacing=1000,round='down',metric=FALSE)dggs <- dgsetres(dggs,res)gridfilename <- dgearthgrid(dggs,savegrid=tempfile(fileext=".shp")) #Save directly to a fileGet table of grid resolution information
Description
Gets a grid's resolution and cell property info as a data frame.
Usage
dggetres(dggs)Arguments
dggs | A dggs object from dgconstruct() |
Value
A data frame containing the resolution levels, number of cells,area of those cells, intercell spacing, and characteristic lengthscale of the cells. All values are in kilometres.
Examples
library(dggridR)dggs <- dgconstruct(res=20)dggetres(dggs)Print info about a dggs object to the screen
Description
dggs objects have many settings. This returns all of them, alongwith info about the grid being specified.
Usage
dginfo(dggs)Arguments
dggs | A dggs object from dgconstruct() |
Value
No return. All info is printed to the screen.
Examples
library(dggridR)dggs <- dgconstruct(res=20)dginfo(dggs)Get largest cell id for a dggs
Description
Cells are labeled 1-N. This function returns N. This is useful ifyou 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 Earthlibrary(dggridR)dggs <- dgconstruct(spacing=1000, metric=FALSE, resround='down')N <- 100 #Number of cellsmaxcell <- dgmaxcell(dggs) #Get maximum cell idcells <- sample(1:maxcell, N, replace=FALSE) #Choose random cellsgrid <- dgcellstogrid(dggs,cells) #Get gridAll earthquakes with magnitude >=3.0 earthquakes for 2015
Description
A data frame with 19914 observations on the following 4 variables.
timeTime of the quake. Example: 2015-12-31T23:39:28.940Z
latLatitude of the epicenter. Example: -7.0711
lonLongitude of the epicenter. Example: -173.5178
magMagnitude of the quake. Example: 3.2
Usage
data(dgquakes)Format
data frame
Source
The USGS Earthquake Hazards Program (https://earthquake.usgs.gov/earthquakes/search/).
Return the coordinates constituting the boundary of cells within aspecified region
Description
Note: This may generate odd results for very largerectangles, because putting rectangles on spheres isweird... as you should know, if you're using this package.
Usage
dgrectgrid( dggs, minlat = -1, minlon = -1, maxlat = -1, maxlon = -1, cellsize = 0.1, ...)Arguments
dggs | A dggs object from dgconstruct() |
minlat | Minimum latitude of region of interest |
minlon | Minimum longitude of region of interest |
maxlat | Maximum latitude of region of interest |
maxlon | Maximum longitude of region of interest |
cellsize | Distance, in degrees, between the sample points used togenerate the grid. Small values yield long generation timeswhile large values may omit cells. |
... | Further arguments passed to |
Value
Returns an sf object.If!is.na(savegrid), returns a filename.
Examples
library(dggridR)dggs <- dgconstruct(spacing=1000,metric=FALSE,resround='down')#Get grid cells for the conterminous United Statesgrid <- dgrectgrid(dggs, minlat=24.7433195, minlon=-124.7844079, maxlat=49.3457868, maxlon=-66.9513812)Saves a generated grid to a shapefile
Description
Saves a generated grid to a shapefile
Usage
dgsavegrid(grid, shpfname)Arguments
grid | Grid to be saved |
shpfname | File to save the grid to |
Value
The filename the grid was saved to
Set the resolution of a dggs object
Description
Set the resolution of a dggs object
Usage
dgsetres(dggs, res)Arguments
dggs | A dggs object from dgconstruct(). |
res | Resolution. Must be in the range [0,30]. Larger values representfiner resolutions. Appropriate resolutions can be found withdg_closest_res_to_area(), dg_closest_res_to_spacing(), anddg_closest_res_to_cls(). Default is 9, which corresponds to acell area of ~2600 sq km and a cell spacing of ~50 km.Default: 9. |
Value
Returns a dggs object which can be passed to other dggridRfunctions
Examples
library(dggridR)dggs <- dgconstruct(res=20)dggs <- dgsetres(dggs,10)Return boundary coordinates for cells intersecting ashapefile
Description
Returns the coordinates constituting the boundary of aset of cells which intersect or are contained by a polygon(or polygons) specified in a shapefile. Note that grid cellsare also generated for holes in the shapefile's polygon(s).
Note that coordinates in the shapefile must be rounded tocheck polygon intersections. Currently this round preserveseight 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 andthe movements of volcanoes. Permanent, corrected,constantly-running GPS base stations might be able toachieve this level of accuracy.
In other words: you should be just fine with this level ofprecision.
Usage
dgshptogrid(dggs, shpfname, cellsize = 0.1, ...)Arguments
dggs | A dggs object from dgconstruct() |
shpfname | Either a sf data frame or the file name of the shapefile. Filename should end with '.shp'. |
cellsize | Distance, in degrees, between the sample points used togenerate the grid. Small values yield long generation timeswhile large values may omit cells. |
... | Further arguments passed to |
Value
Returns an sf object.If!is.na(savegrid), returns a filename.
Examples
library(dggridR)dggs <- dgconstruct(spacing=25, metric=FALSE, resround='nearest')south_africa_grid <- dgshptogrid(dggs,dg_shpfname_south_africa())Verify that a dggs object has appropriate values
Description
Verify that a dggs object has appropriate values
Usage
dgverify(dggs)Arguments
dggs | The dggs object to be verified |
Value
The function has no return value. A stop signal is raised if theobject is misspecified
Examples
library(dggridR)dggs <- dgconstruct(res=20)dgverify(dggs)