latlong2: Convert Latitude and Longitude to US State or County

Description Usage Arguments Value References Examples

View source: R/latlong2.R

Description

Convert latitude and longitude coordinates to US states or US states and counties.

Usage

1
latlong2(pointsDF, to = c("state", "county")[1])

Arguments

pointsDF

A data frame in which the first two columns contain the longitude and latitude in degrees.

to

A character scalar identifying the region to be identified, either "state", the default, or "county".

Value

If to="state", a character vector of state names, all lower case, the same length as the number of rows in pointsDF. If to="county", a character matrix of state and county names, all lower case, with two columns and the same number of rows as pointsDF.

References

Based on a method posted by Josh O'Brien on 6 Jan 2012 on stackoverflow [link].

Examples

1
2
3
testPoints <- data.frame(x=c(-90, -120), y=c(44, 44), z=c("a", "b"))
latlong2(testPoints, to="state")
latlong2(testPoints, to="county")

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.