subsetSDF.SpatialPolygridDataFrame: Subsetting objects of class SpatialPolygridDataFrame

Description Usage Arguments Value Author(s) Examples

Description

Subsetting of the grid by either indices or coordinates, or by a logical mask; subsetting the index or the data.

Usage

1
2
subsetSDF.SpatialPolygridDataFrame(x, locations, data = names(x@data), ..., 
  coord_x, coord_y, grid_i, grid_j, grid_ij)                

Arguments

x

object of class SpatialPolygridDataFrame whereof we want a subset

locations

integer vector: the locations of x with these indices to be kept (refers to x@index); order is taken into account, multiplicity is ignored

data

integer vector or names of columns of the data of x to be kept (refers to x@data)

...

further arguments to be passed to other methods

grid_i

integer vector: the columns of the grid of x to be kept, from top (North) to bottom (South)

grid_j

integer vector: the rows of the grid of x to be kept, from left (West) to right (East)

coord_x

two numerical values: min and max coordinates in x-direction (columns, from West), keep the part in between, including the grid cells with these x-coordinates

coord_y

two numerical values: min and max coordinates in y-direction (rows, from South), keep the part in between, including the grid cells with these y-coordinates

grid_ij

matrix of logical, same size as x (ncol(grid_ij) must be x@grid@grid.cells.dim[1], nrow(grid_ij) must be x@grid@grid.cells.dim[2]); keep values in grid cells where grid_ij is TRUE

For grid_i, grid_j order is ignored, original order of grid is kept.

Value

All subsetting parameters can be combined, the result is the intersection of all parameters, e.g. if index_i and coord_y is given, only the colums that have an index of index_i and coordinates within the limits of coord_y are returned. If invalid values are chosen (outside of the grid), a warning is thrown and the intersection of the parameters with x is used. – Only for data, invalid values result in an error.

The result is a SpatialPolygridDataFrame, cropped to the extent of the remaining grid cells with values. Nonselected parts within this grid are replaced by NA in the index.

Author(s)

Kristina B. Helle, kristina.helle@uni-muenster.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(SPolygridDF)
# subset only attributes
SPolygridDF1 = subsetSDF(SPolygridDF, data = 2)
# subset by locations
SPolygridDF2 = subsetSDF(SPolygridDF, locations = c(1,3,5,7))
# subset by rows and columns of the grid
SPolygridDF3 = subsetSDF(SPolygridDF, grid_i = 3:4, grid_j = 3:9)
# subset by individual grid cells
Grid_ij = matrix(nrow = 6, ncol = 6, byrow = TRUE, data = c(
                         TRUE, FALSE, FALSE, FALSE, FALSE, TRUE,
                        FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
                        FALSE, FALSE,  TRUE,  TRUE, FALSE, FALSE,
                        FALSE, FALSE,  TRUE,  TRUE, FALSE, FALSE,
                         TRUE, FALSE, FALSE, FALSE, FALSE, TRUE,
                        FALSE, FALSE, FALSE, FALSE, FALSE, FALSE))
SPolygridDF4 = subsetSDF(SPolygridDF, grid_ij = Grid_ij)
# subset by bounding box of coordinates
SPolygridDF5 = subsetSDF(SPolygridDF, coord_x = c(3,11), coord_y = c(3,11))

# combined subset (overlap of all subsetting parameters), result has 1 cell
SPolygridDF6 = subsetSDF(SPolygridDF, 
data = "a", locations = 4:1, coord_x = c(0,6), grid_i = 1:3)

KristinaHelle/sensors4plumes documentation built on May 7, 2019, 12:31 p.m.