View source: R/mapGriddedData.r
mapGriddedData | R Documentation |
Produce maps of global gridded data at half degree resolution
mapGriddedData(
dataset = "",
nameColumnToPlot = "",
numCats = 5,
catMethod = "quantiles",
colourPalette = "heat",
xlim = c(-180, 180),
ylim = c(-80, 90),
mapRegion = "world",
addLegend = TRUE,
addBorders = "coarse",
borderCol = "grey",
oceanCol = NA,
landCol = NA,
plotData = TRUE,
aspect = 1,
lwd = 1
)
dataset |
gridded data either as a :
|
nameColumnToPlot |
name of column containing the data to plot |
numCats |
number of categories to put the data in, may be overidden if catMethod ='pretty' |
catMethod |
method for categorisation of data "pretty", "fixedWidth","diverging", "logFixedWidth","quantiles","categorical", or a numeric vector defining breaks |
colourPalette |
a string describing the colour palette to use, choice of :
|
xlim |
map extents c(west,east), can be overidden by mapRegion |
ylim |
map extents c(south,north), can be overidden by mapRegion |
mapRegion |
a country name from getMap()[['NAME']] or 'world','africa','oceania','eurasia','uk' sets map extents, overrides xlim,ylim |
addLegend |
whether to add a legend or not |
addBorders |
options for country borders, 'low','coarse' = low or coarse resolution, 'coasts' = coasts only, 'none' or NA for none |
borderCol |
the colour for country borders |
oceanCol |
a colour for the ocean if the grid values are NA |
landCol |
a colour to fill countries if the grid values are NA over land |
plotData |
whether to plotData, if FALSE a legend can be added on its own |
aspect |
aspect for the map, defaults to 1, if set to 'variable' uses same method as plot.Spatial in sp |
lwd |
line width for country borders |
Plots a map of global half degree gridded data, allowing classification, colours and regions to be set.
Certain catMethod and colourPalette options go well together. e.g. "diverging" and "diverging", "categorical" and "rainbow"
invisibly returns a list containing the data and main options used
for the map, the list can be passed to addMapLegend
along with
additional options to allow greater flexibility in legend creation.
andy south #@importFrom maptools readAsciiGrid
classInt, RColorBrewer
## mapping continuous data
data(gridExData,envir=environment(),package="rworldmap")
gridExData <- get("gridExData")
mapGriddedData(gridExData)
## reclassing continuous data to categorical & mapping
data(gridExData,envir=environment(),package="rworldmap")
#find quartile breaks
cutVector <- quantile(gridExData@data[,1],na.rm=TRUE)
#classify the data to a factor
gridExData@data$categories <- cut( gridExData@data[,1]
, cutVector, include.lowest=TRUE)
#rename the categories
levels(gridExData@data$categories) <- c('low', 'med', 'high', 'vhigh')
#mapping
mapGriddedData( gridExData, nameColumnToPlot= 'categories'
, catMethod='categorical')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.