Description Usage Arguments Value Author(s) References Examples
Plot a Choropleth Map
1 2 |
maptitle |
|
stat |
the column with the statistic to be plotted |
region.map |
if using a polygon |
brew.pal |
defaults to RdYlBu. use display.brewer.all() to see options |
invert.brew.pal |
inverted colour ramp |
cellsmap |
if using a raster etc can be used to show pattern inside polygons, defaults to region.map and therefore overlays. |
scalebar |
if set to false then the axes are ploted |
xl |
xlim values |
yl |
ylim values |
probs |
quantiles at which to break, default is quintiles, limit is 9 |
a map
ivanhanigan
http://stackoverflow.com/questions/1260965/developing-geographic-thematic-maps-with-r
Eduardo Leoni http://stackoverflow.com/a/1261288
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | require(gisviz)
fn <- system.file("etc/shapes/eire.shp", package="spdep")[1]
prj <- CRS("+proj=utm +zone=30 +units=km")
eire <- readShapeSpatial(fn, ID="names", proj4string=prj)
eire2 <- spTransform(eire, CRS("+proj=longlat +datum=WGS84"))
png("test.png")
choropleth(stat="INCOME", region.map=eire2, scalebar = T, xl = c(-8,-6), yl = c(52,53))
dev.off()
Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)
Srs1 = Polygons(list(Sr1), "s1")
Srs2 = Polygons(list(Sr2), "s2")
Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3)
plot(SpP, col = 1:3, pbg="white")
attr = data.frame(a=1:3, b=3:1, row.names=c("s3/4", "s2", "s1"))
SrDf = SpatialPolygonsDataFrame(SpP, attr)
plot(SrDf)
choropleth("title", stat = "b",region.map= SrDf)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.