/usr/share/doc/r-cran-sp/tests/grid.R is in r-cran-sp 1:1.2-5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | library(sp)
data(meuse.grid)
x = meuse.grid
coordinates(x) = c("x", "y")
gridded(x) = TRUE
gridded(x)
image(x["dist"])
fullgrid(x) = TRUE
fullgrid(x)
summary(x)
gridparameters(x)
class(as(x, "matrix"))
fullgrid(x) = FALSE
fullgrid(x)
summary(x)
class(as(x, "matrix"))
gridparameters(x)
df = data.frame(z = c(1:6,NA,8,9),
xc = c(1,1,1,2,2,2,3,3,3),
yc = c(rep(c(0, 1.5, 3),3)))
coordinates(df) = ~xc+yc
gridded(df) = TRUE
gridparameters(df)
as(df, "matrix")
# get grid topology:
grd = points2grid(as(df, "SpatialPoints"), 1e-31)
grd
getGridIndex(coordinates(df), grd)
g = SpatialGrid(grid = grd)
fullgrid(g)
fullgrid(g) = TRUE
class(g)
# the next one has to fail:
fullgrid(g) <- FALSE
class(g)
print(summary(df))
image(df["z"])
as.image.SpatialGridDataFrame(df)
as.image.SpatialGridDataFrame(df["z"])
coordinatevalues(getGridTopology(df))
as.data.frame(df)
fullgrid(df) = TRUE
as.data.frame(df)
fullgrid(df) = FALSE
as.data.frame(df)
fullgrid(df) = TRUE
fullgrid(df) = FALSE
as.data.frame(df)
df = as.data.frame(df)
set.seed(133331)
df$xc = df$xc + rep(.001*rnorm(3), 3)[1:8]
df.sp = SpatialPoints(df[c("xc", "yc")])
df.grd = SpatialPixels(df.sp, tolerance = .01)
df.grd[1:4,,tolerance=.01,drop=TRUE]
df.grd[1:4,,tolerance=.01]
|