Learn R Programming

SpatialPosition (version 0.9)

contourStewart: Create a SpatialPolygonsDataFrame or a SpatialLinesDataFrame from a Stewart Raster

Description

This function create a SpatialPolygonsDataFrame or a SpatialLinesDataFrame from the Stewart raster.

Usage

contourStewart(x, breaks, type = "line")

Arguments

x
raster; output of the rasterStewart function.
breaks
numeric; a vector of break values.
type
character; "poly" or "line". WARNING: the poly option is experimental and needs the rgeos package.

Value

  • The ouput of the function is a SpatialPolygonsDataFrame (type = "poly") or a SpatialLinesDataFrame (type = "line").

See Also

stewart, rasterStewart, plotStewart, contourStewart, CreateGrid, CreateDistMatrix.

Examples

Run this code
data(spatData)
# Compute Stewart potentials from known points (spatPts) on a
# grid defined by its resolution
mystewart <- stewart(knownpts = spatPts, varname = "Capacite",
                     typefct = "exponential", span = 1000, beta = 3,
                     resolution = 50, longlat = FALSE,
                     mask = spatMask)
# Create a raster of potentials values
mystewartraster <- rasterStewart(x = mystewart, mask = spatMask)
# Display the raster and get break values
break.values <- plotStewart(x = mystewartraster)
# Create contour SpatialLinesDataFrame
mystewartcontourlines <- contourStewart(x = mystewartraster,
                                        breaks = break.values,
                                        type = "line")
mystewartcontourlines@data
plot(mystewartcontourlines, col = "grey20", add=TRUE)
plot(spatMask, lwd = 1.25, add=TRUE)
# Create contour SpatialPolygonsDataFrame
mystewartcontourpoly<- contourStewart(x = mystewartraster,
                                      breaks = break.values,
                                      type = "poly")
unique(mystewartcontourpoly@data)
plot(spatMask, col = "grey80", border = "grey50")
plot(mystewartcontourpoly, col = "#0000ff50", border = "grey40",
     add = TRUE)
plot(spatPts, cex = 0.5, pch = 20, col  = "#ff000050", add = TRUE)

Run the code above in your browser using DataLab