Interactive Viewing of Spatial Data in R

Quickly and conveniently create interactive visualisations of spatial data with or without background maps. Attributes of displayed features are fully queryable via pop-up windows. Additional functionality includes methods to visualise true- and false-color raster images, bounding boxes, small multiples and 3D raster data cubes.

Travis-CI Build Status monthly total CRAN License Coverage Status

Interactive viewing of spatial data in R

mapview is an R package created to help researchers during their spatial data analysis workflow. It provides functions to very quickly and conveniently create interactive visualisations of spatial data. It was created to fill the gap of quick (not presentation grade) interactive plotting to examine and visually investigate both aspects of spatial data, the geometries and their attributes.

The main user relevant functions are:

  • mapview - view potentially multiple spatial objects on a set of background maps
  • viewExtent - view extent / bounding box of spatial objects
  • viewRGB - view RGB true- or false-color images of raster objects
  • latticeView & sync - view small multiples of several potentially synchronised maps
  • slideView - view two overlaid raster objects with a horizontal slider to hide/reveal one of them
  • cubeView - 3D view of raster data cubes (e.g. space-time cube) with keyboard control over position of slices
  • plainview - view large rasters on a plain background (i.e. no background map)
  • mapshot - easily save maps (including leaflet maps) as html or png (or other image formats)

Objects of the following spatial classes are supported:

  • sf
  • raster (Layer, Stack, Brick and SpatialPixels* / SpatialGridDataFrame)
  • sp (Points, Polygons, Lines and their DataFrame version)
  • satellite

In addition, mapview provides some extra leaflet compatible functionality:

  • addHomeButton - add zoom-to-layer buttons
  • addLogo - add a logo (or any image really) to a map
  • addFeatures - add features to a map (sf or sp). This is features type agnostic, meaning the same function can be used for points, lines and polygons
  • addMouseCoordinates - add mouse cursor postion information when moving over the map
  • addLargeFeatures - add large data to a map that would otherwise make the leaflet map irresponsive
  • addExtent - add a polygon denoting the extent/bbox of a spatial object to a map
  • popupTable, popupGraph & popupImage - popups of tables, grpahs and images for use with the leaflet add* functions


For CRAN release version of mapview use


To install the development version install the devtools package.

devtools::install_github("r-spatial/[email protected]")


The most basic call


will produce a web map visualisation of the breweries data with the following components:


Please file bug reports and feature requests at

In case of Pull Requests, please make sure to submit them to the develop branch of this repository.


mapview 2.3.0

new features:

  • popupTable has gained argument row.numbers to disable row numbers. #109
  • new function addStarsImage to visualise stars images.
  • new function addImageQuery to provide raster/stars value query on mouseover/click.
  • mapview has gained new argument method to specify the method used for resampling of raster data. #123


  • raster method with = TRUE did throw an error on windows. #111
  • SpatialPixelsDataFrame and SpatialGridDataFrame failed because of missing map argument.
  • example for multiple popupImages was broken. #118
  • SpatialPixelsDataFrame failed when zcol was supplied. #124


  • added more details in description field as per request of Uwe Ligges.
  • moved leaflet from Depends to Imports.

mapview 2.2.0

new features:

  • if supported by the installed leaflet version, legends are now automatically linked to layers.
  • simple features with XYZ, XYM or XYZM geometries are now supported.
  • added function addExtent to add rectangles showing bbox/extent/outline of sf/sp/raster objects.
  • more concise internal recursive method dispatch.
  • if multiple layers are plotted (via "+") initial zoom is now on global extent and a "Zoom full" button is added to the map at the bottom left of the map to re-zoom to this global extent.
  • we now have mapview method for class 'data.frame' which enables interactive scatter plots.
  • we now have mapview method for class 'numeric' which enables interactive plots of a numeric variable.
  • updated slideView to accommodate more than one incident in a flexdashboard #95
  • if supplied data has only one attribute/field column mapview will now colour the plot automatically according to that attribute/field.
  • new mapview method for class 'bbox' -> mapview(st_bbox(x)) is equivalent to viewExtent(x)
  • plainview now provides mouse coordinates


  • added testthat suite of functions.
  • increased performance when using "+"-method (about 10x faster now).


  • manifold bug fixes - addressing issues with list layers, alpha channel and many more.

mapview 2.1.4

new features:

  • popupImage now accepts more than one file name (list or vector) in argument img.


  • na.alpha caused list/burst methods to fail.
  • legend did not work when zcol only had one unique value. This was actually a delibarate choice as for a single map it doesn't really make sense to have a legend for only one color. However, for latticeView/sync this does actually make sense, hence re-enabled.

mapview 2.1.0

new features:

  • plainview/cubeview now respects/has gained argument na.color.
  • mapview now supports st_GEOMETRY with truely mixed feature types (e.g. LINESTRING and POLYGON) - fixes #85
  • addFeatures: one function to add them all. Type agnostic version of leaflet::add* functions for simple features objects.
  • mapview (for vector data only) has gained argument na.alpha to control opacity of missing values.


  • deleted obsolete data.table import.
  • fixed #79: colnames of popupTables are now converted to utf-8.
  • fixed #78: respect explicit setting of '' argument.
  • included NEWS file as R-help doesn't render
  • highlight now respects alpha/alpha.regions = 0

mapview 2.0.1

new features:

  • addMouseCoordinates has gained argument 'style' to specify whether to show 'basic' (lat, lon, zoom) or 'detailed' (x, y, epsg, proj4, lat, lon, zoom) information. Factory-fresh default is 'detailed'.

  • addLogo has gained argument 'alpha' to set the opacity of the image.

  • Someone draws quickest...

  • added new method for list of objects so that we can do mapview(list(x, y, z)) which is great for computational outputs such as lapply.

  • slideView has gained arguments 'label1' and 'label2' to supply slider names for the respective images, img1 and img2.

  • new popup layout (making more use of the space available).

  • added new function addLargeFeatures to render large datasets of up to ~100k features which is used automatically. To lower/elevate the threshold use maxpoints = ... (See ?mapview for details).

  • mapview methods for all basic sf classes (XY/sfg, sfc, sf)

  • added support for sf to "+"

  • we can now render features/objects with arbitrary CRS (without map background) by setting ' = TRUE'.

  • mapview will now decide which default base map to use based on average luminence of rendered colors.

  • mapview now provides subtle highlighting of polygons (changing opacity slightly) and lines (changing thickness).

  • plainView, slideView and cubeView have gained argument legend. default is TRUE. Legends only available for non-RGB methods!

  • new data sets:

    • 'franconia' (administrative district boundaries of Franconia)
    • 'breweries' (extended version of the 'breweries91' data)
    • 'trails' (selected hiking trails in franconia to connect the breweries)
  • data sets 'breweries91', 'gadmCHE' and 'atlStorms2005' have been deleted and moved to leaflet.


  • sync, addMouseCoordinates and addLogo did not work anymore. Now fixed thanks to @timelyportfolio


  • MAJOR internal change: All vector data are now processed as sf objects internally. This also means that objects returned in slot @object will be of class sf (regardless of input class).
  • polygons and points now have a darkish gray line frame (unless add*LargeFeatures is used - where the overhead of passing two sets of colors would be too high).
  • updated examples (in line with new data).
  • github repository moved from to

mapview 1.2.0

new features:

  • garnishMap: function to add multiple decoration elements, such as leaflet::addLayersControl or addHomeButton to a map (mainly for internal use).
  • addHomeButton: add a zoom-to-layer button to a map.
  • addLogo: add an image to a map.
  • plainview now shows CRS and dimension info.


  • na.color was not respected for Raster* and SpatialPiXelsDF.
  • removed lat and lon entries in popupTable for polygons as we now have mousecoordinates.
  • for raster objects the legend did not respect the intervals specified by 'at'.
  • mapview working again for objects with no projection (NA).
  • mapview for SPoints* with only one point did through an error #36.

mapview 1.1.0

new features:

  • addMouseCoordinates: add cursor position information to mapview or leaflet map. (thanks to Kent Russell).
  • if available from leaflet version, a scalebar is added to the map.
  • latticeView: view mapview or leaflet maps as small multiples and sync some, all or none (thanks to Kent Russell).
  • sync: synchronise two or more leaflet maps (thanks to Kenton Russell).
  • mapshot: to save maps as html page or static image or both.
  • knitr integration (i.e. no need to call the @map slot anymore to render in knitr).
  • cubeView: view raster bricks or stacks hovmoeller style, use keys up & down, left & right, page up & page down to navigate through y, x, z dimensions, respectively.
  • labels: if zcol is set, mouseover will now show the repesctive values of zcol, if zcol is not set moseover shows feature ID. Only available if suitable leaflet package version is installed.
  • new popup functions popupTable, popupGraph and popupImage.
  • functions to turn coordinates into spatial lines or spatial polygons.
  • mapview objects now work natively on shiny applications (i.e. renderMapview and mapviewOutput now available).
  • "zcol = Var" in combination with burst = TRUE now plots one layer for each unique value of the variable supplied to zcol.


  • spplot method has been removed.
  • colors: viridis based colors now default if viridisLite package is available.
  • basemaps: new default basemap is "CartoDB.Positron" as colors of features are better visible on the grey background.
  • layer names now include the name of the object they originate from (e.g. "meuse lead" instead of "lead").


  • if attribute was of class "character" mapview did through an error if passed to zcol.
  • user provided layer names were not respected when zcol was set. See also note on changes in default layer names.

mapview 1.0.0

  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.3.0 by Tim Appelhans, 2 months ago

Report a bug at

Browse source code at

Authors: Tim Appelhans [cre, aut], Florian Detsch [aut], Christoph Reudenbach [aut], Stefan Woellauer [aut], Spaska Forteva [ctb], Thomas Nauss [ctb], Edzer Pebesma [ctb], Kenton Russell [ctb], Michael Sumner [ctb], Environmental Informatics Marburg [ctb]

Documentation:   PDF Manual  

Task views: Analysis of Spatial Data

GPL (>= 3) | file LICENSE license

Imports leaflet, sp, raster, satellite, scales, brew, htmlwidgets, htmltools, png, Rcpp, lattice, gdalUtils, webshot, viridisLite, sf, base64enc, svglite, uuid

Depends on methods

Suggests knitr, rmarkdown, dplyr, testthat, covr

Linking to Rcpp

System requirements: GNU make

Imported by lidR, mapedit, rpostgisLT, tmap.

Suggested by sf, uavRmp.

See at CRAN