Last data update: 2014.03.03
R: View spatial objects interactively
View spatial objects interactively
Description
this function produces an interactive view of the specified
spatial object(s) on top of the specified base maps.
Usage
## S4 method for signature 'RasterLayer'
mapView(x, map = NULL,
maxpixels = mapviewGetOption("mapview.maxpixels"),
col.regions = mapviewGetOption("raster.palette")(256), at = NULL,
na.color = mapviewGetOption("na.color"), use.layer.names = FALSE,
values = NULL, map.types = mapviewGetOption("basemaps"),
alpha.regions = 0.8, legend = mapviewGetOption("legend"),
legend.opacity = 1, trim = TRUE, verbose = mapviewGetOption("verbose"),
layer.name = deparse(substitute(x, env = parent.frame())), ...)
## S4 method for signature 'RasterStackBrick'
mapView(x, map = NULL,
maxpixels = mapviewGetOption("mapview.maxpixels"),
col.regions = mapviewGetOption("raster.palette")(256), at = NULL,
na.color = mapviewGetOption("na.color"), values = NULL,
map.types = mapviewGetOption("basemaps"),
legend = mapviewGetOption("legend"), legend.opacity = 1, trim = TRUE,
verbose = mapviewGetOption("verbose"), ...)
## S4 method for signature 'Satellite'
mapView(x, map = NULL,
maxpixels = mapviewGetOption("mapview.maxpixels"),
col.regions = mapviewGetOption("raster.palette")(256), at = NULL,
na.color = mapviewGetOption("na.color"), values = NULL,
map.types = mapviewGetOption("basemaps"),
legend = mapviewGetOption("legend"), legend.opacity = 1, trim = TRUE,
verbose = mapviewGetOption("verbose"), ...)
## S4 method for signature 'SpatialPixelsDataFrame'
mapView(x, zcol = NULL, ...)
## S4 method for signature 'SpatialGridDataFrame'
mapView(x, zcol = NULL, ...)
## S4 method for signature 'SpatialPointsDataFrame'
mapView(x, map = NULL,
map.types = mapviewGetOption("basemaps"), zcol = NULL, burst = FALSE,
color = mapviewGetOption("vector.palette"), alpha = 0.8,
col.regions = color, alpha.regions = 0.2,
na.color = mapviewGetOption("na.color"), at = NULL, cex = 8, lwd = 4,
popup = popupTable(x), label, legend = mapviewGetOption("legend"),
legend.opacity = 1, layer.name = deparse(substitute(x, env =
parent.frame())), verbose = mapviewGetOption("verbose"), ...)
## S4 method for signature 'SpatialPoints'
mapView(x, map = NULL, zcol = NULL,
color = mapviewGetOption("vector.palette")(1),
na.color = mapviewGetOption("na.color"), cex = 8, lwd = 4,
alpha = 0.9, alpha.regions = 0.4,
map.types = mapviewGetOption("basemaps"),
verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x,
env = parent.frame())), label, ...)
## S4 method for signature 'SpatialPolygonsDataFrame'
mapView(x, map = NULL,
map.types = mapviewGetOption("basemaps"), zcol = NULL, burst = FALSE,
color = mapviewGetOption("vector.palette"), alpha = 0.8,
col.regions = color, alpha.regions = 0.2,
na.color = mapviewGetOption("na.color"), at = NULL, cex = 8, lwd = 2,
popup = popupTable(x), label, legend = mapviewGetOption("legend"),
legend.opacity = 1, layer.name = deparse(substitute(x, env =
parent.frame())), verbose = mapviewGetOption("verbose"), ...)
## S4 method for signature 'SpatialPolygons'
mapView(x, map = NULL,
color = mapviewGetOption("vector.palette")(1),
na.color = mapviewGetOption("na.color"),
map.types = mapviewGetOption("basemaps"), lwd = 2, alpha = 0.8,
alpha.regions = 0.2, verbose = mapviewGetOption("verbose"),
layer.name = deparse(substitute(x, env = parent.frame())), label, ...)
## S4 method for signature 'SpatialLinesDataFrame'
mapView(x, map = NULL,
map.types = mapviewGetOption("basemaps"), zcol = NULL, burst = FALSE,
color = mapviewGetOption("vector.palette"), alpha = 0.8,
col.regions = color, alpha.regions = 0.2,
na.color = mapviewGetOption("na.color"), at = NULL, cex = 8, lwd = 2,
popup = popupTable(x), label, legend = mapviewGetOption("legend"),
legend.opacity = 1, layer.name = deparse(substitute(x, env =
parent.frame())), verbose = mapviewGetOption("verbose"), ...)
## S4 method for signature 'SpatialLines'
mapView(x, map = NULL, zcol = NULL,
color = mapviewGetOption("vector.palette")(1),
na.color = mapviewGetOption("na.color"), lwd = 2, alpha = 0.8,
map.types = mapviewGetOption("basemaps"),
verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x,
env = parent.frame())), label, ...)
## S4 method for signature 'missing'
mapView(map.types = mapviewGetOption("basemaps"),
easter.egg = FALSE)
## S4 method for signature 'ANY'
mapview(...)
Arguments
x
a Raster*
or Spatial*
object.
map
an optional existing map to be updated/added to
maxpixels
integer > 0. Maximum number of cells to use for the plot.
If maxpixels < ncell(x)
, sampleRegular is used before plotting.
col.regions
color (palette) pixels.
See levelplot
for details.
at
the breakpoints used for the visualisation.
See levelplot
for details.
na.color
color for missing values
use.layer.names
should layer names of the Raster* object be used?
values
a vector of values for the visualisation of the layers.
Per default these are calculated based on the supplied raster* object.
map.types
character spcifications for the base maps.
see http://leaflet-extras.github.io/leaflet-providers/preview/
for available options.
alpha.regions
opacity of the fills or the raster layer(s)
legend
should a legend be plotted
legend.opacity
opacity of the legend
trim
should the raster be trimmed in case there are NAs on the egdes
verbose
should some details be printed during the process
layer.name
the name of the layer to be shown on the map
...
additional arguments passed on to repective functions.
See addRasterImage
, addCircles
,
addPolygons
, addPolylines
for details
zcol
attribute name(s) or column number(s) in attribute table
of the column(s) to be rendered. See also Details.
burst
whether to show all (TRUE) or only one (FALSE) layer(s).
See also Details.
color
color (palette) for points/polygons/lines
alpha
opacity of the lines or points
cex
attribute name(s) or column number(s) in attribute table
of the column(s) to be used for defining the size of circles
lwd
line width
popup
a list
of HTML strings with the popup contents, usually
created from popupTable
. See addControl
for
details.
label
a character vector of labels to be shown on mouseover. See
addControl
for details.
easter.egg
well, you might find out if you set this to TRUE
Details
If zcol
is not NULL
but a length one character vector
(referring to a column name of the attribute table)
and burst
is TRUE
, one layer for each unique value
of zcol
will be drawn. The same will happen if burst
is
a length one character vector (again referring to a column of
the attribute table).
The usage of big data sets is performed by loading local copies
of json files from temporary storage. This works fine for most of
the current browsers. If you are using Google's chrome browser you have to
start the browser with the flag -allow-file-access-from-files
(i.e
for windows: "path_to_your_chrome_installationchrome.exe –allow-file-access-from-files",
for linux: "/usr/bin/google-chrome –allow-access-from-files").
See http://www.chrome-allow-file-access-from-file.com/ for further details.
Methods (by class)
RasterStackBrick
: stack
/ brick
Satellite
: satellite
SpatialPixelsDataFrame
: SpatialPixelsDataFrame
SpatialGridDataFrame
: SpatialGridDataFrame
SpatialPointsDataFrame
: SpatialPointsDataFrame
SpatialPoints
: SpatialPoints
SpatialPolygonsDataFrame
: SpatialPolygonsDataFrame
SpatialPolygons
: SpatialPolygons
SpatialLinesDataFrame
: SpatialLinesDataFrame
SpatialLines
: SpatialLines
missing
: initiate a map without an object
ANY
: alias for ease of typing
Author(s)
Tim Appelhans
Examples
## Not run:
mapview()
### raster data ###
library(sp)
library(raster)
# SpatialPixelsDataFrame
data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
proj4string(meuse.grid) <- CRS("+init=epsg:28992")
gridded(meuse.grid) <- TRUE
mapView(meuse.grid, zcol = "soil")
# raster stack
m1 <- mapview(poppendorf[[5]])
m1
### point vector data ###
## SpatialPointsDataFrame ##
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
# all layers of meuse
mapview(meuse, burst = TRUE)
# only one layer, all info in popups
mapview(meuse)
# one specific layer
mapview(meuse, zcol = "soil") # one layer
mapview(meuse, zcol = "soil", burst = TRUE) # three layers
mapview(meuse, burst = "soil") # identical to above
## SpatialPoints ##
meuse_pts <- as(meuse, "SpatialPoints")
mapview(meuse_pts)
### overlay vector on top of raster ###
mapview(meuse.grid, zcol = "ffreq") + meuse
### polygon vector data ###
data("gadmCHE")
m <- mapview(gadmCHE)
m
## points on polygons ##
centres <- data.frame(coordinates(gadmCHE))
names(centres) <- c("x", "y")
coordinates(centres) <- ~ x + y
projection(centres) <- projection(gadmCHE)
m + centres
### lines vector data
data("atlStorms2005")
mapview(atlStorms2005)
mapview(atlStorms2005, burst = TRUE)
## End(Not run)
Results