Unlimited learning, half price | 50% off
Get 50% off unlimited learning

mapview (version 2.3.0)

addImageQuery: Add image query functionality to leaflet/mapview map.

Description

Add image query functionality to leaflet/mapview map.

Usage

addImageQuery(map, x, group = NULL, layerId = NULL, project = TRUE,
  type = c("mousemove", "click"), digits, position = "topright", ...)

Arguments

map

the map with the RasterLayer to be queried.

x

the RasterLayer that is to be queried.

group

the group of the RasterLayer to be queried.

layerId

the layerId of the RasterLayer to be queried. Needs to be the same a supplied in addRasterImage.

project

whether to project the RasterLayer to conform with leaflets expected crs. Defaults to TRUE and things are likely to go haywire if set to FALSE.

type

whether query should occur on 'mousemove' or 'click'. Defaults to 'mousemove'.

digits

the number of digits to be shown in the display field.

position

where to place the display field. Default is 'topright'.

...

currently not used.

Value

A leaflet map object.

Details

This function enables Raster* objects added to leaflet/mapview maps to be queried. Standard query is on 'mousmove', but can be changed to 'click'. Note that for this to work, the layerId needs to be the same as the one that was set in addRasterImage. Currently only works for numeric values (i.e. numeric/integer and factor values are supported).

Examples

Run this code
# NOT RUN {
library(leaflet)
library(mapview)

leaflet() %>%
  addProviderTiles("OpenStreetMap") %>%
  addRasterImage(poppendorf[[1]], project = TRUE, group = "poppendorf",
                 layerId = "poppendorf") %>%
  addImageQuery(poppendorf[[1]], project = TRUE,
                layerId = "poppendorf") %>%
  addLayersControl(overlayGroups = "poppendorf")


# }

Run the code above in your browser using DataLab