A function to provide spplot-like plotting capability but NOT using trellis graphics. This function also acts as an interface for fast plotting of SpatialPolygonsDataFrame or SpatialPixelsDataFrame objects using leaflet HTML plotting capabilities to get zoomable plots with real-world context: transformation to the correct projection is done automatically.
spplot1(
x,
what,
palette = brewer.pal(5, "Oranges"),
breaks = NULL,
legpos = "topleft",
fun = identity,
include.lowest = TRUE,
bty = "n",
bg = NULL,
printlegend = TRUE,
bw = FALSE,
useLeaflet = FALSE,
urltemplate = urlTemplate("Stamen_Toner"),
fillOpacity = 0.5,
legendOpacity = 0.5,
OSMbg = NULL,
leafletLegend = TRUE,
alpha.f = 0.5,
plotinorder = FALSE,
legendText = NULL,
legendFun = NULL,
...
)
a SpatialPolgonsDataFrame or a SpatialPointsDataFrame
the name of the variable to plot
the palette, can either be a vector of names of colours, or a vector of colours produced for example by the brewer.pal function.
optional breaks for the legend, a vector of length 1 + length(palette)
the position of the legend, options are 'topleft', 'topright', 'bottomleft', 'bottomright'
an optional function of the data to plot, default is the identity function
see ?cut
see ?legend
see ?legend
logical: print the legend?
Logical. Plot in black/white/greyscale? Default is to produce a colour plot. Useful for producing plots for journals that do not accept colour plots.
whether to use leaflet to produce a zoomable map this requires the leaflet package, available by issuing the command "devtools::install_github('rstudio/leaflet')"
template for leaflet map background, default is urlTemplate('Stamen-Toner'), but any valid web address for leaflet templates will work here. See ?urlTemplate.
see ?addPolygons
see opacity argument in function addLegend
optional OpenStreetMap background to add to plot, obtain this using the function getBackground
logical, display the leaflet legend?
point transparency, see ?adjustcolor, default is 0.5
whether to plot in order of the size of the variable being plotted, useful for overlapping windows where small counts may obscure big counts
X
X
other arguments to be passed to plot
either produces a plot or if useLeaflet is TRUE, returns a leaflet map widget to which further layers can be added
See http://leaflet-extras.github.io/leaflet-providers/preview/ for examples of leaflet templates.
Instructions on installing the leaflet R package are available from https://rstudio.github.io/leaflet/
urlTemplate, getBackground, brewer.pal