Aliases: SpatialPixels SpatialGrid GridTopology SpatialGrid plot.SpatialGrid coordinatevalues points2grid getGridIndex getGridTopology areaSpatialGrid
Keywords: spatial
### ** Examples x = GridTopology(c(0,0), c(1,1), c(5,4)) class(x)
[1] "GridTopology" attr(,"package") [1] "sp"
x
X1 X2 cellcentre.offset 0 0 cellsize 1 1 cells.dim 5 4
summary(x)
Grid topology: cellcentre.offset cellsize cells.dim 1 0 1 5 2 0 1 4
coordinates(x)
s1 s2 [1,] 0 3 [2,] 1 3 [3,] 2 3 [4,] 3 3 [5,] 4 3 [6,] 0 2 [7,] 1 2 [8,] 2 2 [9,] 3 2 [10,] 4 2 [11,] 0 1 [12,] 1 1 [13,] 2 1 [14,] 3 1 [15,] 4 1 [16,] 0 0 [17,] 1 0 [18,] 2 0 [19,] 3 0 [20,] 4 0
coordinates(GridTopology(c(0,0), c(1,1), c(5,4)))
s1 s2 [1,] 0 3 [2,] 1 3 [3,] 2 3 [4,] 3 3 [5,] 4 3 [6,] 0 2 [7,] 1 2 [8,] 2 2 [9,] 3 2 [10,] 4 2 [11,] 0 1 [12,] 1 1 [13,] 2 1 [14,] 3 1 [15,] 4 1 [16,] 0 0 [17,] 1 0 [18,] 2 0 [19,] 3 0 [20,] 4 0
coordinatevalues(x)
$s1 [1] 0 1 2 3 4 $s2 [1] 3 2 1 0
data(meuse.grid) coordinates(meuse.grid) <- c("x", "y") points2grid(meuse.grid)
x y cellcentre.offset 178460 329620 cellsize 40 40 cells.dim 78 104
data(meuse.grid) set.seed(1) meuse.grid$x <- meuse.grid$x + rnorm(length(meuse.grid$x), 0, 0.002)
Error in `$<-`(`*tmp*`, x, value = c(`1` = 181179.998747092, `2` = 181140.000367287, : x is a coordinate name, please choose another name
meuse.grid$y <- meuse.grid$y + rnorm(length(meuse.grid$y), 0, 0.002)
Error in `$<-`(`*tmp*`, y, value = c(`1` = 333739.999737807, `2` = 333699.999906476, : y is a coordinate name, please choose another name
coordinates(meuse.grid) <- c("x", "y")
Error in `coordinates<-`(`*tmp*`, value = c("x", "y")): setting coordinates cannot be done on Spatial objects, where they have already been set
#EJP # points2grid(meuse.grid, tolerance=0.76, round=1) data(meuse.grid) a <- which(meuse.grid$x == 180140) b <- which(meuse.grid$x == 180180) c <- which(meuse.grid$x == 179260) d <- which(meuse.grid$y == 332460) e <- which(meuse.grid$y == 332420) f <- which(meuse.grid$y == 330740) meuse.grid <- meuse.grid[-c(a, b, c, d, e, f),] coordinates(meuse.grid) <- c("x", "y")
Error in `coordinates<-`(`*tmp*`, value = c("x", "y")): setting coordinates cannot be done on Spatial objects, where they have already been set
points2grid(meuse.grid)
Warning in points2grid(meuse.grid): grid has empty column/rows in dimension 1
Warning in points2grid(meuse.grid): grid has empty column/rows in dimension 2
x y cellcentre.offset 178460 329620 cellsize 40 40 cells.dim 78 104
data(meuse.grid) set.seed(1) meuse.grid$x <- meuse.grid$x + rnorm(length(meuse.grid$x), 0, 0.002)
Error in `$<-`(`*tmp*`, x, value = c(`1` = 181179.998747092, `2` = 181140.000367287, : x is a coordinate name, please choose another name
meuse.grid$y <- meuse.grid$y + rnorm(length(meuse.grid$y), 0, 0.002)
Error in `$<-`(`*tmp*`, y, value = c(`1` = 333739.998988322, `2` = 333700.001156517, : y is a coordinate name, please choose another name
meuse.grid <- meuse.grid[-c(a, b, c, d, e, f),] coordinates(meuse.grid) <- c("x", "y")
Error in `coordinates<-`(`*tmp*`, value = c("x", "y")): setting coordinates cannot be done on Spatial objects, where they have already been set
# EJP # points2grid(meuse.grid, tolerance=0.69, round=1)