Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addImageQuery

Add image query functionality to leaflet/mapview map.


Description

Add image query functionality to leaflet/mapview map.

Usage

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

Arguments

map

the map with the RasterLayer to be queried.

x

the RasterLayer that is to be queried.

band

for stars layers, the band number 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 as supplied in addRasterImage or addStarsImage.

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'.

prefix

a character string to be shown as prefix for the layerId.

className

a character string to append to the control legend.

...

currently not used.

Details

This function enables Raster*/stars 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 or addStarsImage. Currently only works for numeric values (i.e. numeric/integer and factor values are supported).

Value

A leaflet map object.

Examples

if (interactive()) {
  if (requireNamespace("plainview")) {
    library(leaflet)
    library(plainview)

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

leafem

'leaflet' Extensions for 'mapview'

v0.1.3
MIT + file LICENSE
Authors
Tim Appelhans [cre, aut], Christoph Reudenbach [ctb], Kenton Russell [ctb], Jochen Darley [ctb], Daniel Montague [ctb] (Leaflet.EasyButton plugin), Lorenzo Busetto [ctb], Luigi Ranghetti [ctb], Miles McBain [ctb], Sebastian Gatscha [ctb], Björn Harrtell [ctb] (FlatGeobuf plugin), Daniel Dufour [ctb] (georaster-layer-for-leaflet)
Initial release
2020-07-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.