Debian Codegraph @

man/SpatialGrid.Rd

raw
1 \name{SpatialPixels}
2 \alias{SpatialPixels}
3 \alias{SpatialGrid}
4 \alias{GridTopology}
5 \alias{SpatialGrid}
6 \alias{plot.SpatialGrid}
7 \alias{coordinatevalues}
8 \alias{points2grid}
9 \alias{getGridIndex}
10 \alias{getGridTopology}
11 \alias{areaSpatialGrid}
12 \title{ define spatial grid }
13 \description{
14 defines spatial grid by offset, cell size and dimensions
15 }
16 \usage{
17 GridTopology(cellcentre.offset, cellsize, cells.dim)
18 SpatialPixels(points, tolerance = sqrt(.Machine$double.eps),
19 proj4string = CRS(as.character(NA)), round = NULL, grid = NULL)
20 SpatialGrid(grid, proj4string = CRS(as.character(NA)))
21 coordinatevalues(obj)
22 points2grid(points, tolerance = sqrt(.Machine$double.eps), round=NULL)
23 getGridIndex(cc, grid, all.inside = TRUE)
24 getGridTopology(obj)
25 areaSpatialGrid(obj)
26 }
27 \arguments{
28 \item{cellcentre.offset}{numeric; vector with the smallest centroid coordinates for
29 each dimension; coordinates refer to the cell centre}
30 \item{cellsize}{numeric; vector with the cell size in each dimension}
31 \item{cells.dim}{integer; vector with number of cells in each dimension}
32 \item{points}{ coordinates, object of class \link{SpatialPoints-class} }
33 \item{grid}{ grid topology; object of class \link{GridTopology-class};
34 for calls to \code{SpatialPixels}, a value of NULL implies that this will
35 be derived from the point coordinates }
36 \item{tolerance}{ precision, used to which extent points are exactly on
37 a grid}
38 \item{round}{default NULL, otherwise a value passed to as the digits argument to \code{round} for setting cell size}
39 \item{proj4string}{ object of class \link{CRS-class}}
40 \item{obj}{object of class or deriving from \link{SpatialGrid-class}}
41 \item{cc}{ numeric matrix with coordinates }
42 \item{all.inside}{ logical; if TRUE and \code{cc} points fall outside
43 the grid area, an error message is generated; if FALSE, NA values
44 are generated for such points }
45 }
46
47 \value{ GridTopology returns a value of class \link{GridTopology-class};
48 SpatialGrid returns an object of class \link{SpatialGrid-class}
49
50 \code{coordinatevalues} returns a list with the unique x-coordinates,
51 the unique y-coordinate, etc. instead of the \link{coordinates} of all
52 grid cells
53
54 SpatialGrid returns an object of class \link{SpatialGrid-class}.
55
56 points2grid returns the \link{GridTopology-class} from a set of points.
57
58 getGridIndex finds the index of a set of point coordinates in a given
59 grid topology, and depending on \code{all.inside} setting, generates NA
60 or an error message if points are outside the grid domain.
61
62 getGridTopology returns the slot of class \link{GridTopology-class} from
63 obj.
64
65 areaSpatialGrid returns the spatial area of (the non-missing valued cells
66 of) the grid. For objects of class \link{SpatialGridDataFrame-class}
67 the area refers to cells where any (one or more) of the attribute columns
68 are non-missing valued.
69 }
70
71 \note{
72 SpatialGrid stores grid topology and may or may not store the coordinates
73 of the actual points, which may form a subset of the full grid. To find
74 out or change this, see \link{fullgrid}.
75
76 points2grid tries to figure out the grid topology from points. It succeeds
77 only if points on a grid line have constant y column, and points on a
78 grid column have constant x coordinate, etc. In other cases, use signif
79 on the raw coordinate matrices to make sure this is the case.
80 }
81
82
83 \author{ Edzer Pebesma, \email{[email protected]}}
84
85 \seealso{
86 \link{SpatialGrid-class},
87 \link{SpatialGridDataFrame-class},
88 }
89
90 \examples{
91 x = GridTopology(c(0,0), c(1,1), c(5,4))
92 class(x)
93 x
94 summary(x)
95 coordinates(x)
96 coordinates(GridTopology(c(0,0), c(1,1), c(5,4)))
97 coordinatevalues(x)
98 data(meuse.grid)
99 coordinates(meuse.grid) <- c("x", "y")
100 points2grid(meuse.grid)
101 data(meuse.grid)
102 set.seed(1)
103 meuse.grid$x <- meuse.grid$x + rnorm(length(meuse.grid$x), 0, 0.002)
104 meuse.grid$y <- meuse.grid$y + rnorm(length(meuse.grid$y), 0, 0.002)
105 coordinates(meuse.grid) <- c("x", "y")
106 #EJP
107 # points2grid(meuse.grid, tolerance=0.76, round=1)
108 data(meuse.grid)
109 a <- which(meuse.grid$x == 180140)
110 b <- which(meuse.grid$x == 180180)
111 c <- which(meuse.grid$x == 179260)
112 d <- which(meuse.grid$y == 332460)
113 e <- which(meuse.grid$y == 332420)
114 f <- which(meuse.grid$y == 330740)
115 meuse.grid <- meuse.grid[-c(a, b, c, d, e, f),]
116 coordinates(meuse.grid) <- c("x", "y")
117 points2grid(meuse.grid)
118 data(meuse.grid)
119 set.seed(1)
120 meuse.grid$x <- meuse.grid$x + rnorm(length(meuse.grid$x), 0, 0.002)
121 meuse.grid$y <- meuse.grid$y + rnorm(length(meuse.grid$y), 0, 0.002)
122 meuse.grid <- meuse.grid[-c(a, b, c, d, e, f),]
123 coordinates(meuse.grid) <- c("x", "y")
124 # EJP
125 # points2grid(meuse.grid, tolerance=0.69, round=1)
126 }
127
128 \keyword{spatial}