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

identify.map

Identify regions on a map


Description

Identifies the map regions clicked by the user.

Usage

## S3 method for class 'map'
identify(x, n = 1, index = FALSE, ...)

Arguments

x

a map object containing named polygons.

n

the number of clicks to wait for.

index

If TRUE, returns the index of the polygon, rather than its name.

...

additional arguments passed to identify.default.

Details

The current algorithm is somewhat crude — selects the region whose centroid is closest to the click. A more sophisticated approach would use map.where.

Value

a character vector of length n, naming the selected regions.

Author(s)

Tom Minka

See Also

Examples

identify(map("state", fill = TRUE, col = 0))
if(require(mapproj))
  identify(map("world", proj = "lagrange", fill = TRUE, col = 0, wrap=c(-180,180,-90)))

maps

Draw Geographical Maps

v3.3.0
GPL-2
Authors
Original S code by Richard A. Becker and Allan R. Wilks. R version by Ray Brownrigg. Enhancements by Thomas P Minka and Alex Deckmyn.
Initial release
2018-04-03

We don't support your browser anymore

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