setGridOrder {gmGeostats} | R Documentation |
Set or get the ordering of a grid
Description
Specify or retrieve the ordering in which a grid is stored in a vector (or matrix).
Usage
setGridOrder(x, refpoint, cycle)
setGridOrder_sp(x, G = 2)
setGridOrder_array(x, G = 2)
gridOrder_sp(G = 2)
gridOrder_gstat(G = 2)
gridOrder_array(G = 2)
gridOrder_GSLib(G = 2)
Arguments
x |
a data container for the elements of the grid; the grid order is stored as an attribute to it |
refpoint |
a string specifying which point of the grid corresponds
to the first element of |
cycle |
a permutation of the integers |
G |
number of geographic dimensions of the setting, typically |
Details
A "gridOrder" attribute is a list consisting of two named elements:
- refpoint
one of "topleft", "bottomleft", "topright" or "bottomright" in 2D, or also of "topleftsurf", "bottomleftsurf", "toprightsurf", "bottomrightsurf", "topleftdeep","bottomleftdeep", "toprightdeep" or "bottomrightdeep" in 3D ("deep" is accessory, i.e. "topleft"== "topleftdeep"), indicating the location on the grid of the first point of the object
x
- cycle
a permutation of
1:G
indicating in which order run the dymensions, from faster to slower
Thus, a conventional ordering of a (nX*nY)-element vector into a matrix to plot with graphics::image()
corresponds to an refpoint="bottomleft"
and cycle=1:2
, i.e. start with the lower left corner
and run first by rows (eastwards), then by columns (northwards). This is constructed by
gridOrder_array(G)
, and can be directly set to an object x
by setGridOrder_array(x,G)
;
gridOrder_GSLib
is an alias for gridOrder_array
.
The grids from package "sp" (and many other in R), on the contrary follow the convention
refpoint="topleft"
and cycle=1:2
, i.e. start with the upper left corner
and run first by rows (eastwards), then by columns (southwards). This is constructed by
gridOrder_sp(G)
, and can be directly set to an object x
by setGridOrder_sp(x,G)
; gridOrder_gstat
is an alias for gridOrder_sp
.
Value
setGridOrder(x,...)
returns the object x
with the grid order description attached
as an attribute "gridOrder"; getGridOrder(x)
retrieves this attribute and returns it.
Functions
-
setGridOrder_sp
: Set or get the ordering of a grid -
setGridOrder_array
: Set or get the ordering of a grid -
gridOrder_sp
: Set or get the ordering of a grid -
gridOrder_gstat
: Set or get the ordering of a grid -
gridOrder_array
: Set or get the ordering of a grid -
gridOrder_GSLib
: Set or get the ordering of a grid
See Also
sortDataInGrid()
for ways of reordering a grid
Examples
gt = sp::GridTopology(cellcentre.offset=c(1,11), cellsize=c(1,1), cells.dim=c(5,3))
sp::coordinates(sp::SpatialGrid(grid=gt))
gridOrder_sp(2)