Return State Names at Specified Locations

Share:

Description

Uses spatial comparison to determine which 'state' polygons the locations fall into and returns the ISO 3166-2 2-character state code strings for those polygons.

Specification of countryCodes limits spatial searching to the specified countries and greatly improves performance.

If allData=TRUE, additional data is returned.

Usage

1
2
getStateName(lon, lat, dataset = "NaturalEarthAdm1", countryCodes = NULL,
  allData = FALSE, useBuffering = FALSE)

Arguments

lon

vector of longitudes in decimal degrees

lat

vector of latitudes in decimal degrees

dataset

name of spatial dataset to use

countryCodes

vector of country codes

allData

logical specifying whether to return a full dataframe

useBuffering

logical flag specyfing the use of location buffering to find the nearest polygon if not target polygon is found

Value

Vector of state names in English

See Also

getSpatialData

Examples

1
2
3
4
5
6
## Not run: 
lon <- seq(-140,-90)
lat <- seq(20,70)
getStateName(lon,lat)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.