(CC-BY-NC-SA)
This document was produced on So Jun 12 2016 using mapview version 1.1.0
Despite the possibility to quickly plot spatial data with mapview(x), mapview() has a set of arguments for finer control of the visualization. Depending on the object class, these are:
All types
map - the leaflet or mapview map to use -> default NULLcol.regions - the color palette for coluring raster and polygon data -> default viridisLite::inferno for raster data and viridisLite::viridis for vector dataat - breakpoints used for the colouring -> default NULL meaning they are calculated automatically for the range of datana.color - the color for NA values -> default #BEBEBE80map.types - the types of the background maps -> default CartoDB.Positron, OpenStreetMap, Esri.WorldImagery, Thunderforest.Landscape, OpenTopoMap see here for available map typesalpha.regions - the opacity of raster and polygon fills -> default 0.2 for polygons and 0.8 for rasterslegend - whether to add a legend to the plot -> default FALSElegend.opacity - opacity of the legend -> default 1verbose - whether to print additional information to the console during the rendering -> default FALSElayer.name - the layer name to be used for plotting -> default depends on call. For a single object the name of the object; if zcol is supplied a combination of object name and column name; for raster stack/bricks the layer namesaddRasterImage or adCircleMarkersraster only
maxpixels - the maximum number of pixels to plot -> default 500k. This is used so rendering doesn’t take forever. This can also be set with mapviewOptions()use.layer.names - whether to use the layer names of raster objects -> default FALSEtrim - should rasters be trimmed off NA values around the edges -> default TRUEvector only
zcol - attribute name(s) or column number(s) in attribute table of the column(s) to be rendered -> default NULLburst - whether to show all (TRUE) or only one (FALSE) layer(s) -> default FALSEcolor - color (palette) for points/polygons/lines -> default viridisLite::viridisalpha - opacity of the lines or points -> default 0.8cex - circle size for point data -> default 8. This can also be used to map circle size to an attribute from the object’s attribute table by supplying either column name or numberlwd - line width -> default 2label - a character vector of labels to be shown on mouseover -> default feature IDs, if zcol is set the values of zcolpopup - the popup function to use for the popups -> default popupTable(). See chapter on popups for further optionsHere’s a few examples of how selected arguments can be used:
Similar to spplot arguments col.regions and at can be used for finer control of the colouring
library(mapview)
library(raster)
library(RColorBrewer)
pal <- colorRampPalette(brewer.pal(9, "BrBG"))
kili_data <- system.file("extdata", "kiliNDVI.tif", package = "mapview")
kiliNDVI <- stack(kili_data)
mapview(kiliNDVI[[1]], col.regions = pal(100), at = seq(-0.2, 1, 0.2), legend = TRUE)mapview(breweries91, zcol = "founded", at = seq(1400, 2200, 200), legend = TRUE)To use a different background map, use argument map.types
mapview(breweries91, map.types = c("CartoDB.DarkMatter", "OpenStreetMap.DE"), color = "grey40")To individually label the layer names use argument layer.name
library(mapview)
library(sp)
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
mapview(meuse, zcol = c("lead", "landuse"), 
        layer.name = c("Concentration of lead", "Lanuse type"))burst can be used to plot all layers of a Spatial*DataFrame object
library(mapview)
library(sp)
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
mapview(meuse, burst = TRUE)when used together with zcol, burst will produce one layer for all unique values of zcol.
mapview(meuse, zcol = "soil", burst = TRUE, color = c("darkred", "forestgreen", "cornflowerblue"), legend = TRUE)Note that for a column with many values there will likely not be enough space for the layers control - we are working on a solution for this issue.
mapview(breweries91, zcol = "zipcode", burst = TRUE, legend = TRUE)For SpatialPointsDataFrames the circle size can be mapped to one of the attributes
mapview(meuse, zcol = "soil", cex = "cadmium")