MazamaSpatialUtils (version 0.6.4)

getStateCode: Return state ISO codes at specified locations

Description

Uses spatial comparison to determine which 'state' polygons the locations fall into and returns the ISO 3166 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

getStateCode(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 a full dataframe should be returned

useBuffering

logical flag specifying the use of location buffering to find the nearest polygon if no target polygon is found

Value

Vector of ISO-3166-2 alpha-2 state codes.

See Also

getSpatialData

Examples

Run this code
# NOT RUN {
lon <- seq(-140,-90)
lat <- seq(20,70)
getStateCode(lon,lat)
# }

Run the code above in your browser using DataCamp Workspace