map.where: Locate points on a map

Description Usage Arguments Value Note Author(s) See Also Examples

Description

Returns the region names containing given locations.

Usage

1
map.where(database = "world", x, y, ...)

Arguments

database

character string naming a geographical database, or a list of x, y, and names. See the documentation for map for more details.

x

vector of longitudes.

y

vector of latitudes.

...

Options for SpatialPolygons2map, only used if database is of type SpatialPolygonsDataFrame

.

Value

A list of character strings, naming the map region that each (longitude, latitude) pair falls into.

Note

This function may give erroneous results if the database contains enclaves. For instance, a point in San Marino may also be identified as being in Italy.

Author(s)

Tom Minka

See Also

in.polygon

Examples

1
2
3
4
5
6
7
8
9
# NYC
map.where("state", -73.8, 41)
# Auckland
map.where("nz", 174.6, -36.92)
# find both in the world
map.where(x = c(174.6, -73.8), y = c(-36.92, 41))
# with a map object:
m = map("state", "new york", fill = TRUE, plot = FALSE)
map.where(m, -73.8, 41)

Example output

[1] "new york:main"
[1] "North.Island "
[1] "New Zealand:North Island" "USA"                     
[1] "new york:main"

maps documentation built on May 2, 2019, 3:29 p.m.