map.where.Rd
Returns the region names containing given locations.
map.where(database = "world", x, y, ...)
character string naming a geographical database, or a list of
x
, y
, and names
.
See the documentation for map for more details.
vector of longitudes.
vector of latitudes.
Options for SpatialPolygons2map
, only used if database
is of type SpatialPolygonsDataFrame
.
A list of character strings, naming the map region that each (longitude, latitude) pair falls into.
in.polygon
For points close to a border (polygon boundary), the result may be wrong if the resolution of the database is insufficient. This function may also give erroneous results if the database contains enclaves. For instance, a point in San Marino may also be identified as being in Italy.
# NYC
map.where("state", -73.8, 41)
#> [1] "new york:main"
# Auckland
map.where("nz", 174.6, -36.92)
#> [1] "North.Island "
# find both in the world
map.where(x = c(174.6, -73.8), y = c(-36.92, 41))
#> [1] "New Zealand:North Island" "USA"
# with a map object:
m = map("state", "new york", fill = TRUE, plot = FALSE)
map.where(m, -73.8, 41)
#> [1] "new york:main"