| 1 |
flipHorizontal <- function(x) { |
| 2 |
if (!inherits(x, "SpatialGridDataFrame")) stop("x must be a SpatialGridDataFrame") |
| 3 |
grd <- getGridTopology(x) |
| 4 |
idx = 1:prod([email protected][1:2]) |
| 5 |
m = matrix(idx, [email protected][2], [email protected][1], byrow = TRUE)[,[email protected][1]:1] |
| 6 |
idx = as.vector(t(m)) |
| 7 |
x@data <- x@data[idx, TRUE, drop = FALSE] |
| 8 |
x |
| 9 |
} |
| 10 |
|
| 11 |
flipVertical <- function(x) { |
| 12 |
if (!inherits(x, "SpatialGridDataFrame")) stop("x must be a SpatialGridDataFrame") |
| 13 |
grd <- getGridTopology(x) |
| 14 |
idx = 1:prod([email protected][1:2]) |
| 15 |
m = matrix(idx, [email protected][2], [email protected][1], byrow = TRUE)[[email protected][2]:1, ] |
| 16 |
idx = as.vector(t(m)) |
| 17 |
x@data <- x@data[idx, TRUE, drop = FALSE] |
| 18 |
x |
| 19 |
} |