Closed dankelley closed 1 year ago
I'm seeing the same thing with Gavin Simpson's canadaHCD
package. Actually, it doesn't work because it has some errors that relate, I think, to changes in tibble
-related code (see below), but I went into his code to see the URL, and when I download that (this time as CSV) I get headings but no data. Clearly env-can has -- yet again -- changed the format.
> library(canadaHCD)
> find_station("Halifax")
# A tibble: 13 × 5
Name Province StationID LatitudeDD LongitudeDD
<fct> <fct> <fct> <dbl> <dbl>
1 BABINE LAKE HALIFAX BAY British Columbia 455 55.0 -126.
2 HALIFAX Nova Scotia 6355 44.6 -63.6
3 HALIFAX Nova Scotia 6356 44.6 -63.6
4 HALIFAX CITADEL Nova Scotia 6357 44.6 -63.6
5 HALIFAX COMMONS Nova Scotia 49128 44.6 -63.6
6 HALIFAX DOCKYARD Nova Scotia 43405 44.7 -63.6
7 HALIFAX INTL A Nova Scotia 53938 44.9 -63.5
8 HALIFAX STANFIELD INT'L A Nova Scotia 6358 44.9 -63.5
9 HALIFAX INTL A Nova Scotia 50620 44.9 -63.5
10 HALIFAX KOOTENAY Nova Scotia 43124 44.6 -63.6
11 HALIFAX WINDSOR PARK Nova Scotia 43403 44.7 -63.6
12 HALIFAX RADAR Nova Scotia 9030 44.9 -63.5
13 HALIFAX METOC Nova Scotia 10879 44.7 -63.6
> d <- hcd_hourly(6357,2023,09)
Rows: 720 Columns: 30
── Column specification ──────────────────────────────────────────────
Delimiter: ","
chr (3): Station Name, Month, Day
dbl (4): Longitude (x), Latitude (y), Climate ID, Year
lgl (21): Temp (°C), Temp Flag, Dew Point Temp (°C), Dew Point Te...
dttm (1): Date/Time (LST)
time (1): Time (LST)
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Error:
! Names repair functions can't return `NA` values.
Run `rlang::last_trace()` to see where the error occurred.
It's not broken, actually. The station codes have changed, I guess. If I use e.g.
library(dod)
metFile <- dod.met(43405, 2023, 9, age=1, type="csv")
it works. (That is the Halifax Dockyard dataset.)
Maybe the code number for Halifax Stanfield has changed, etc. You'd think I could check on that by going to https://weather.gc.ca/city/pages/ns-19_metric_e.html and I do see a link there that brings me to https://climate.weather.gc.ca/climate_data/daily_data_e.html?StationID=50620 so I guess the code for the airport is now 50620 (which is number 9 in the list from canadaHCD::find_station()
.
Actually, there are 3 items in that list that are for the airport. Maybe when they change equipment they change the number. Or maybe they keep moving the station? I've no idea, but I do know that this issue -- as defined by its title -- is ready to be closed.
See https://github.com/dankelley/oce/issues/2151 but note that I plan to fix it here, in
dod
, porting it back tooce
only if I find it works well.Another approach, which I find quite appealing, is to "deprecated" the oce version. I just don't like having a function that requires major changes on a year or even sub-year basis, and that is what happens with met data from Environment Canada (or whatever it names itself this week).