[R-sig-Geo] Spatial tradeoffs/optimization in R?

Lyndon Estes lyndon.estes at gmail.com
Wed Oct 17 00:14:32 CEST 2012


Dear List,

I am writing to ask for some pointers about whether a particular
method can be performed in R.  I have the following type of analysis I
would like to perform:

*Say I have three land uses X, Y, and Z.

*Each land use has a target amount of total production (P) that should
be achieved, which is found by summing the production across grid
cells devoted (or fractionally devoted) to the particular land use.
The production amount is heterogeneous in the raster.

*Given the three target values P (P_X, P_Y, P_Z), I want to explore:
a. The effect that meeting P_X has on P_Y and P_Z (etc.)
b. Find the most optimal solution (and the spatial pattern produced by
that solution), where either P_X, P_Y, and P_Z are satisfied or come
as close to being satisfied as possible.

I am imagining an approach in which a routine seeks the solution by
finding the fewest number of pixels required to meet each target,
starting with the most productive pixels and moving to the least
productive.

I could imagine the code that would allow the least number of pixels
to be converted while minimizing the land needed to reach the target.
e.g.

library(raster)
X <- raster(xmn = 0, xmx = 10, ymn = 0, ymx = 10)
res(X) <- 0.1
X[] <- sample(10:100, size = ncell(X), replace = T)
v <- getValues(X)
P <- round(sum(v) * 0.2)
vm <- data.frame(cbind("ID" = 1:length(v), v))
vmr <- vm[order(vm$v, decreasing = T), ]
vmr$csum <- cumsum(vmr$v)
cids <- vmr[1:which.min(abs(vmr$csum - rep(P, nrow(vmr)))), "ID"]  #
IDs of cells to convert

X.lu <- X * 0  # Empty raster to find land use area for X needed to hit target
X.lu[cids] <- 1  # Set to 1 to indicate areas converted to X

plot(X)
plot(X.lu)

I could then do a crude approach where the land uses are converted in
different order, with a constraint set for each successive one that it
cannot use pixels already converted to meet the previous use.

However, I imagine there is a better and established way to do it, and
see online that there are spatial optimization approaches.  However,
is there a way to do this in R?

Any advice/suggestions will be highly appreciated.

Thanks, Lyndon



More information about the R-sig-Geo mailing list