gmGeostats (version 0.11.3)

sortDataInGrid: Reorder data in a grid

Description

Reorder the data in a compact grid, changing between ordering specifications

Usage

sortDataInGrid(
  x,
  grid = attr(x, "grid"),
  orderIn = attr(x, "gridOrder"),
  orderOut = list(refpoint = "bottomleft", cycle = 1:2)
)

Value

the data from x (typically a matrix), but reordered as orderOut

Arguments

x

gridded data

grid

grid topology underlying

orderIn

current ordering description (see setGridOrder())

orderOut

desired output ordering description (see setGridOrder())

See Also

setGridOrder() for ways of specifying the grid ordering

Examples

Run this code
if (FALSE) {
getTellus(cleanup=TRUE, TI=TRUE)
load("Tellus_TI.RData")
coords = as.matrix(Tellus_TI[,1:2])
compo = compositions::acomp(Tellus_TI[,3:7])
dt = spatialGridAcomp(coords=coords, compo=compo)
image_cokriged(dt, ivar="MgO", breaks = NULL) 
x = sort(unique(coords[,1]))
y = sort(unique(coords[,2]))
x0 = c(min(x), min(y))
Ax = c(mean(diff(x)), mean(diff(y)))
n = c(length(x), length(y))
gr = sp::GridTopology(cellcentre.offset=x0, cellsize=Ax, cells.dim=n)
dt0 = sortDataInGrid(Tellus_TI, grid=gr, orderIn=gridOrder_array(2), 
                    orderOut=list(refpoint="bottomright", cycle=2:1))
coords = as.matrix(dt0[,1:2])
compo = compositions::acomp(dt0[,3:7])
spatialGridAcomp(coords=coords, compo=compo)
}

Run the code above in your browser using DataLab