Learn R Programming

mapview (version 1.0.0)

mapView: 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

## S3 method for class 'RasterLayer':
mapView(x, map = NULL,
  maxpixels = mapviewGetOption("maxpixels"),
  col.regions = mapviewGetOption("raster.palette")(256), at,
  na.color = mapviewGetOption("na.color"), use.layer.names = FALSE,
  values = NULL, map.types = mapviewGetOption("basemaps"),
  alpha.regions = 0.8, legend = TRUE, legend.opacity = 1, trim = TRUE,
  verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x,
  env = parent.frame())), ...)

## S3 method for class 'RasterStackBrick': mapView(x, map = NULL, maxpixels = mapviewGetOption("maxpixels"), col.regions = mapviewGetOption("raster.palette")(256), at, na.color = mapviewGetOption("na.color"), values = NULL, map.types = mapviewGetOption("basemaps"), legend = FALSE, legend.opacity = 1, trim = TRUE, verbose = mapviewGetOption("verbose"), ...)

## S3 method for class 'Satellite': mapView(x, ...)

## S3 method for class 'SpatialPixelsDataFrame': mapView(x, zcol = NULL, ...)

## S3 method for class 'SpatialPointsDataFrame': mapView(x, zcol = NULL, map = NULL, burst = FALSE, color = mapviewGetOption("vector.palette")(256), na.color = mapviewGetOption("na.color"), cex = 10, lwd = 2, alpha = 0.6, alpha.regions = 0.2, map.types = mapviewGetOption("basemaps"), legend = FALSE, legend.opacity = 1, verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x, env = parent.frame())), popup = NULL, ...)

## S3 method for class 'SpatialPoints': mapView(x, map = NULL, zcol = NULL, color = "#460000", na.color = mapviewGetOption("na.color"), cex = 10, lwd = 2, alpha = 0.6, alpha.regions = 0.2, map.types = mapviewGetOption("basemaps"), verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x, env = parent.frame())), ...)

## S3 method for class 'SpatialPolygonsDataFrame': mapView(x, zcol = NULL, map = NULL, burst = FALSE, color = mapviewGetOption("vector.palette")(256), na.color = mapviewGetOption("na.color"), lwd = 2, alpha = 0.8, alpha.regions = 0.2, values = NULL, map.types = mapviewGetOption("basemaps"), legend = FALSE, legend.opacity = 1, verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x, env = parent.frame())), popup = NULL, ...)

## S3 method for class 'SpatialPolygons': mapView(x, map = NULL, color = "#460000", na.color = mapviewGetOption("na.color"), map.types = mapviewGetOption("basemaps"), lwd = 2, alpha.regions = 0.8, verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x, env = parent.frame())), ...)

## S3 method for class 'SpatialLinesDataFrame': mapView(x, zcol = NULL, map = NULL, burst = FALSE, color = mapviewGetOption("vector.palette")(256), na.color = mapviewGetOption("na.color"), lwd = 2, alpha = 0.8, values = NULL, map.types = mapviewGetOption("basemaps"), legend = FALSE, legend.opacity = 1, verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x, env = parent.frame())), popup = NULL, ...)

## S3 method for class 'SpatialLines': mapView(x, map = NULL, zcol = NULL, color = "#460000", 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())), ...)

## S3 method for class 'missing': mapView(map.types = mapviewGetOption("basemaps"), easter.egg = FALSE)

## S3 method for class 'ANY': mapview(...)

Arguments

x
a raster* 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
zcol
attribute name(s) or column number(s) in attribute table of the column(s) to be rendered
burst
whether to show all (TRUE) or only one (FALSE) layers
color
color (palette) for points/polygons/lines
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
alpha
opacity of the lines or points
popup
a character vector of the HTML content for the popups. See addControl for details.
easter.egg
well, you might find out if you set this to TRUE

Methods (by class)

Examples

Run this code
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[[10]])
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)

## 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)

Run the code above in your browser using DataLab