contourStewart: Create a SpatialPolygonsDataFrame or a SpatialLinesDataFrame...

Description Usage Arguments Details Value See Also Examples

View source: R/contourStewart.R

Description

contourStewart is deprecated.
To obtain contour lines use rasterToContour from raster package.
To obtain contour polygons use rasterToContourPoly from SpatialPosition package.


This function creates a SpatialPolygonsDataFrame or SpatialLinesDataFrame contour from the Stewart raster.

Usage

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

Arguments

x

raster; output of the rasterStewart function. The raster must contain only positive values.

breaks

numeric; a vector of break values.

mask

SpatialPolygonsDataFrame; mask used to clip contour shapes.

type

character; "poly" or "line". WARNING: the poly option is experimental (see details). It needs the rgeos package.

Details

To obtain a correct SpatialPolygonsDataFrame of potentials follow theses steps:

See also the second example in the examples section.

Value

The ouput of the function is a SpatialPolygonsDataFrame (type = "poly") or a SpatialLinesDataFrame (type = "line"). The data frame of the outputed SpatialPolygonsDataFrame contains four fields: id (id of each polygon), min and max (minimum and maximum breaks of the polygon), mean (center value of the class)

See Also

rasterToContourPoly.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
data("spatData")
## Not run: 
#### Example with type = "line"
mystewart <- stewart(knownpts = spatPts, varname = "Capacite",
                     typefct = "exponential", span = 1000, beta = 3,
                     resolution = 50,
                     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
mystewartcontourpoly <- contourStewart(x = mystewartraster,
                                       breaks = break.values,
                                       type = "line")
# Display the Map
plot(spatMask, add=TRUE)
plot(mystewartcontourpoly, border = "grey40",add = TRUE)
plot(spatPts, cex = 0.8, pch = 20, col  = "black", add = TRUE)



#### Example with type = "poly"
mystewart <- stewart(knownpts = spatPts, varname = "Capacite",
                     typefct = "exponential", span = 1000, beta = 3,
                     resolution = 50, longlat = FALSE,
                     mask = spatMask)
# Create a raster of potentials valuesn, no mask
mystewartraster <- rasterStewart(x = mystewart)
# Display the raster and get break values
break.values <- plotStewart(x = mystewartraster)
# Create contour SpatialLinesDataFrame
mystewartcontourpoly <- contourStewart(x = mystewartraster,
                                       breaks = break.values,
                                       mask = spatMask,
                                       type = "poly")
# Display the map
library(cartography)
opar <- par(mar = c(0,0,1.1,0))
choroLayer(spdf = mystewartcontourpoly, 
           df = mystewartcontourpoly@data, 
           var = "mean", legend.pos = "topleft",
           breaks = break.values, border = "grey90", 
           lwd = 0.2, 
           legend.title.txt = "Potential number\nof beds in the\nneighbourhood", 
           legend.values.rnd = 0)
plot(spatMask, add = TRUE)
propSymbolsLayer(spdf = spatPts, df = spatPts@data, var = "Capacite",
                 legend.title.txt = "Number of beds", 
                 col = "#ff000020")
layoutLayer(title = "Global Accessibility to Public Hospitals", 
            south = TRUE, sources = "", author = "")
par(opar)

## End(Not run)

SpatialPosition documentation built on Sept. 6, 2017, 5:04 p.m.