TranslateStateCodes: Translate standard state names, abbreviations, and codes.

Description Usage Arguments Details Examples

Description

TranslateStateCodes particularly translates USGS state_cd to other formats. Data from: https://www.census.gov/geo/reference/ansi_statetables.html and particularly http://www2.census.gov/geo/docs/reference/state.txt The returnVal choice determines the format returned. Choices are: "STATE" is the FISP state code in the range of 1-78 (with some missing). "STUSAB" is the common or postal 2 letter abreviation. "STATE_NAME" is the full name. "STATENS" is Geographic Names Information System Identifier (GNISID)

Usage

1
2
TranslateStateCodes(inVector, returnVal = c("STATE", "STUSAB",
  "STATE_NAME", "STATENS")[2])

Arguments

inVector

integer or character, a vector of one of the types of to convert. Not case sensitive for strings.

returnVal

Character string for the desired output format. Defaults to STUSAB and this choice overrides when the output type is the same as the input type.

Details

See internals of code to get the details of the data frame used for the translation.

Examples

1
2
3
4
5
6
7
stNums <- c(1,15,25, 5, 50, NA)
ab <- tolower(TranslateStateCodes(stNums))
ab
names <- TranslateStateCodes(ab); names  ## note default for abs in is names out
gnis <- TranslateStateCodes(tolower(names),'STATENS'); gnis
num <- TranslateStateCodes(gnis,'STATE'); num
all(num==stNums, na.rm=TRUE)

mccreigh/rwrfhydro documentation built on Feb. 28, 2021, 1:53 p.m.