| create_PolyGrids | R Documentation |
Create a polygon grid to spatially aggregate data in cells of chosen size.
Cell size may be specified in degrees or as a desired area in square kilometers
(in which case cells are of equal area). Using Blank=TRUE (with caution) produces
an empty grid.
create_PolyGrids(
Input,
NamesIn = NULL,
dlon = NA,
dlat = NA,
Area = NA,
cuts = 100,
cols = c("green", "yellow", "red"),
Blank = FALSE
)
Input |
input dataframe. If Latitude, Longitude, Variable 1, Variable 2 ... Variable x. |
NamesIn |
character vector of length 2 specifying the column names of Latitude and Longitude fields in
the
|
dlon |
numeric, width of the grid cells in decimal degrees of longitude. |
dlat |
numeric, height of the grid cells in decimal degrees of latitude. |
Area |
numeric, area in square kilometers of the grid cells. The smaller the |
cuts |
numeric, number of desired color classes. |
cols |
character, desired colors. If more that one color is provided, a linear color gradient is generated. |
Blank |
logical, |
Spatial object in your environment.
if Blank=FALSE:
Data within the resulting spatial object contains the data provided in the Input after aggregation
within cells. For each Variable, the minimum, maximum, mean, sum, count, standard deviation, and,
median of values in each cell is returned. In addition, for each cell, its area (AreaKm2), projected
centroid (Centrex, Centrey) and unprojected centroid (Centrelon, Centrelat) is given. Also, colors are
generated for each aggregated values according to the chosen cuts and cols. To generate a
custom color scale after the grid creation, refer to add_col and add_Cscale.
if Blank=TRUE:
An empty grid is generated. It can be re-used across scripts in conjunction
with assign_areas.
create_Points, create_Lines, create_Polys,
create_Stations, create_Pies, add_col,
add_Cscale, add_Legend.
# For more examples, see:
# https://github.com/ccamlr/CCAMLRGIS#create-grids
# And:
# https://github.com/ccamlr/CCAMLRGIS/blob/master/Advanced_Grids/Advanced_Grids.md
#Simple grid, using automatic colors
MyGrid=create_PolyGrids(Input=GridData,dlon=2,dlat=1)
#View(MyGrid)
plot(st_geometry(MyGrid),col=MyGrid$Col_Catch_sum)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.