Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

get_historical() station ids don't align with other outputs #127

Closed
adamhsparks opened this issue Feb 12, 2021 · 3 comments
Closed

get_historical() station ids don't align with other outputs #127

adamhsparks opened this issue Feb 12, 2021 · 3 comments
Labels

Comments

@adamhsparks
Copy link
Collaborator

adamhsparks commented Feb 12, 2021

I've used sweep_for_stations() to identify weather stations for which I wanted historical data and get_historical() to download the stations. However, the type of data is not standard for the station id values. sweep_for_stations() returns a character value with BOM's leading 0s, get_historical() returns a numeric value that strips the leading 0s, which is inconsistent across the package functions and makes it difficult to join tables where you may have the ID as a character value and numeric elsewhere.

@jonocarroll, was this your intended functionality? I'd prefer that the functions that share returned values follow a consistent approach if at all possible and @HughParsonage's handling of the station IDs makes more sense to me initially since the leading "0" and "00" have meaning, but I'm open to discussion.

@jonocarroll
Copy link
Collaborator

That's most likely an oversight on my part - get_historical() should absolutely keep things in the package-standard format. From what I can see, the returned stationid should be unchanged from input as it's output here https://github.com/ropensci/bomrang/blob/master/R/get_historical_weather.R#L124 which is essentially

sweep_for_stations(latlon = latlon)[1, , drop = TRUE]$site

The only place I see it converted is in the comparison here https://github.com/ropensci/bomrang/blob/master/R/get_historical_weather.R#L147

I'm not at a computer I can test with at the minute, but which output has the numeric value? Is that in the station attribute or the ncc_list$site attribute? The latter comes from e.g. http://www.bom.gov.au/climate/data/lists_by_element/alphaAUS_136.txt which are integer without padding, and that's my best guess at what's going on.

@adamhsparks
Copy link
Collaborator Author

It's the station_number col from get_historical()

The band-aid solution for the moment is this for my work.

  mutate(station_number = case_when(
    nchar(station_number) == 4 ~ paste0("00", station_number),
    TRUE ~ paste0("0", station_number)
  ))

@adamhsparks
Copy link
Collaborator Author

Thanks for the quick fix. Looks good to me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants