header_tag.html

Skip to contents

Function to simplify finding county and county code definitions. Used in readNWISdata and readNWISuse. Currently only has US counties.

Usage

countyCdLookup(state, county, outputType = "fips")

Arguments

state

could be character (full name, abbreviation, id), or numeric (id)

county

could be character (name, with or without "County") or numeric (id)

outputType

character can be "fullName", "tableIndex", "id", or "fullEntry".

Examples

# \donttest{

fips <- countyCdLookup(state = "WI", county = "Dane")
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/counties?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
id <- countyCdLookup(state = "WI", county = "Dane", outputType = "id")
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/counties?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
name <- countyCdLookup(state = "OH", county = 13, output = "fullName")
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/counties?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
entry <- countyCdLookup(state = "Pennsylvania", county = "ALLEGHENY COUNTY", output = "fullEntry")
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/counties?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
fromIDs <- countyCdLookup(state = 13, county = 5, output = "fullName")
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/counties?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
#> GET: https://api.waterdata.usgs.gov/samples-data/codeservice/states?mimeType=application%2Fjson
# }