sp (version 0.8-4)

as.SpatialPolygons.GridTopology: Make SpatialPolygons object from GridTopology object

Description

Converts grids of regular rectangles into a SpatialPolygons object, which can be transformed to a different projection or datum. The function is not suitable for high-resolution grids. The ordering of the grid cells is as in coordinates() of the same object, and is reported by IDvaluesGridTopology.

Usage

as.SpatialPolygons.GridTopology(grd, proj4string = CRS(as.character(NA)))
IDvaluesGridTopology(obj)

Arguments

grd,obj
GridTopology object
proj4string
projection string of class CRS

Value

  • as.SpatialPolygons.GridTopology returns a SpatialPolygons object; IDvaluesGridTopology returns a character vector with the GridTopology object column and row indices.

See Also

GridTopology, SpatialPolygons

Examples

Run this code
grd <- GridTopology(cellcentre.offset=c(-175,55), cellsize=c(10,10), cells.dim=c(4,4))
SpP_grd <- as.SpatialPolygons.GridTopology(grd)
plot(SpP_grd)
text(getSpPPolygonsLabptSlots(SpP_grd), getSpPPolygonsIDSlots(SpP_grd), cex=0.5)
trdata <- data.frame(A=rep(c(1,2,3,4), 4), B=rep(c(1,2,3,4), each=4), row.names=getSpPPolygonsIDSlots(SpP_grd))
SpPDF <- SpatialPolygonsDataFrame(SpP_grd, trdata)
spplot(SpPDF)

Run the code above in your browser using DataCamp Workspace