Grid2Polygons: Convert Spatial Grids to Polygons

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/Grid2Polygons.R

Description

This function has been deprecated; please use inlmisc::Grid2Polygons instead. Used to convert sp spatial objects from class 'SpatialGridDataFrame' to 'SpatialPolygonsDataFrame'. Spatial polygons can then be transformed to a different projection or datum with spTransform in package rgdal. Image files created with spatial polygons are reduced in size and result in a much "cleaner" version of your image.

Usage

1
2
Grid2Polygons(grd, zcol = 1, level = FALSE, at, cuts = 20,
  pretty = FALSE, xlim = NULL, ylim = NULL, ply = NULL, ...)

Arguments

grd

SpatialGridDataFrame. Spatial grid data frame

zcol

character or integer. Attribute name or column number in attribute table.

level

logical. If true, a set of levels is used to partition the range of z, its default is false.

at

numeric. A vector giving breakpoints along the range of z.

cuts

integer. Number of levels the range of z would be divided into.

pretty

logical. Whether to use pretty cut locations.

xlim

numeric. Vector of length 2 giving left and right limits of the spatial grid, data outside these limits is excluded.

ylim

numeric. Vector of length 2 giving lower and upper limits of the spatial grid, data outside these limits is excluded.

ply

SpatialPolygons, or SpatialGridDataFrame. Cropping polygon

...

Not used

Details

Converts sp spatial objects from class SpatialGridDataFrame to SpatialPolygonsDataFrame. Spatial polygons can then be transformed to a different projection or datum with spTransform in package rgdal. Image files created with spatial polygons are reduced in size and result in a much "cleaner" version of your image.

Value

Returns an object of SpatialPolygonsDataFrame. The objects data slot is a data frame, number of rows equal to the number of Polygons objects and a single column containing values of z. If level is true, z values are set equal to the midpoint between breakpoints. The status of the polygon as a hole or an island is taken from the ring direction, with clockwise meaning island, and counter-clockwise meaning hole.

Note

The traditional R graphics model does not draw polygon holes correctly, holes overpaint their containing Polygon object using a user defined background color (white by default). Polygon holes are now rendered correctly using the plot method for spatial polygons (SpatialPolygons-class), see polypath for more details. The Trellis graphics model appears to rely on the traditional method so use caution when plotting with spplot.

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

References

A general explanation of the algorithm provided here; inspiration provided here.

See Also

Grid2Polygons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
data(meuse.grid, package = "sp")
sp::coordinates(meuse.grid) <- ~ x + y
sp::gridded(meuse.grid) <- TRUE
meuse.grid <- as(meuse.grid, "SpatialGridDataFrame")
meuse.plys <- Grid2Polygons(meuse.grid, "dist", level = FALSE)
op <- par(mfrow = c(1, 2), oma = rep(0, 4), mar = rep(0, 4))
sp::plot(meuse.plys, col = heat.colors(length(meuse.plys)))
title("level = FALSE", line = -7)
meuse.plys.lev <- Grid2Polygons(meuse.grid, "dist", level = TRUE)
sp::plot(meuse.plys.lev, col = heat.colors(length(meuse.plys.lev)))
title("level = TRUE", line = -7)
par(op)

## End(Not run)

Grid2Polygons documentation built on Aug. 4, 2017, 1:01 a.m.