lat_long2state: United States of America (USA) State Identification Using...

lat_long2stateR Documentation

United States of America (USA) State Identification Using Latitude/Longitude Coordinates

Description

Using the provided latitude/longitude coordinates (as character or numeric vectors), this function determines whether the location is within an United States of America (USA) state/commonwealth, Puerto Rico, or the U.S. Virgin Islands

Usage

lat_long2state(latitude, longitude)

Arguments

latitude

numeric vector (or character vector with numbers only) that contains the latitude as a decimal degree

longitude

numeric vector (or character vector with numbers only) that contains the longitude as a decimal degree

Value

the location name as a character vector (United States of America (USA) state/commonwealth, Puerto Rico, or the U.S. Virgin Islands

Author(s)

Irucka Embry, Josh O'Brien (Stack Overflow R code)

Source

Latitude Longitude Coordinates to State Code in R - Stack Overflow answered by Josh O'Brien on Jan 6 2012 and edited by Josh O'Brien on Jun 18, 2020. See https://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r.

Examples


# Example 1

library(iemisc)

lat_long2state(latitude = c(36.3684553, 40), longitude = c(-82.1796880, -89))
lat_long2state(latitude = "36.3684553", longitude = "-82.1796880")



# Example 2

# Test the function using points in Wisconsin and Oregon (From Source 1)

library(iemisc)

x = c(-90, -120); y = c(44, 44)
lat_long2state(latitude = y, longitude = x)





iemisc documentation built on Sept. 25, 2023, 5:09 p.m.