jsta / nhdR

R interface to the National Hydrography Dataset :droplet:
https://jsta.github.io/nhdR/
37 stars 12 forks source link

nhd_get not recognizing Alaska #90

Closed hrecht closed 1 year ago

hrecht commented 1 year ago

Hi, thanks for the great package. I'm trying to get data for Alaska and am getting this error message:

> nhd_get(state = "AK")
Error in FUN(X[[i]], ...) : AK is not a valid state abbreviation

It looks like the issue stems from this line of code. I'm not familiar with the maps library but it seems to not have Alaska in it. https://github.com/jsta/nhdR/blob/master/R/get.R#L19

One solution would be to switch to R's built in state.abb dataset plus DC and the territories.

jsta commented 1 year ago

Thanks for the heads-up. My preference would be to add "AK" to the subsequent line (L20) of that file. Getting automated package checking to recognize built-in datasets can be a real pain in my experience.

hrecht commented 1 year ago

I feel that pain! It looks like it is working here though? https://github.com/jsta/nhdR/blob/master/R/utils.R#L289 Another option would be to add your own simple dataset of the postal abbreviations and state names, and that could include territories as well. I do something similar for state fips codes in my censusapi package.

Some other U.S. territories that seem to not be recognized but do have NHD state files: American Samoa, Guam, Northern Mariana Islands.

jsta commented 1 year ago

Awesome1 Let's go with your initial suggestion then.

Relevant state/territory code key: https://en.wikipedia.org/wiki/List_of_U.S._state_and_territory_abbreviations

hrecht commented 1 year ago

This is working now, thanks for such a quick fix!