-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Precipitation data #413
Comments
I am not sure yet but I suspect that it's a change to the API as with the NCDC data I'm working on with issue #412 |
Would the data pull fix on #412 work for my problem? ncdc2? |
I was hoping this was going to be an easier problem to solve but the API has completely changed and it's broken most of the functions in the package. They still work for now, but only for old data as you've found. Essentially, every function needs to be rewritten. So it's a related problem but will require a unique solution. I unfortunately don't have a timeframe for the solution. |
Can I pull data with ncdc2 instead? |
Thanks for checking into it. Let me know if you find a workaround. These data is very important as I need to update a fish model soon to predict salmon returns to the PWS area for commercial fishing. Thanks |
So I think it should work for you if you since you have a vector of station ID. Give your code a try like this: lat_lon_df <- data.frame(id = "pw",
lat = 60.690545,
lon = -147.097055)
mon_near_pw <-
meteo_nearby_stations(
lat_lon_df = lat_lon_df,
lat_colname = "lat",
lon_colname = "lon",
var = "PRCP",
year_min = 2011,
year_max = 2021,
limit = 20,
)
rnoaa:::ncdc2(datasetid='daily-summaries',
datatypeid = 'PRCP',
stationid = mon_near_pw$pw$id[c(1,3,11,14)],
startdate = '2011-01-01',
enddate = '2013-12-01')$data |>
dplyr::rename(id = station) |>
dplyr::mutate(prcp = prcp * 10) This code renames things to match your old code and converts the precipitation values back to the same units as from the old code I believe. Very neat project. I actually work for NMFS and not on the weather-side of NOAA. |
Trying it. Will let you know if it works. |
Yes the three colons allow you to use a non-exported function.
Sent from a handheld device.
… On Oct 29, 2022, at 5:50 PM, Felipe ***@***.***> wrote:
I went ahead and reinstalled rnoaa:
***@***.***_api")
But I am getting the following error message:
Error: 'ncdc2' is not an exported object from 'namespace:rnoaa'
Did you intentionally are calling ncdc2 like this: rnoaa:::ncdc2() or is a typo?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were assigned.
|
Works great. I can pull data now up to December 2021. |
I also noticed that the NOAA temperature API is not updating. https://www.ndbc.noaa.gov/histsearch.php?station=46061&year=2021&f1=wtmp&t1a=lt&v1a=100&t1b=&v1b=&c1=&f2=&t2a=&v2a=&t2b=&v2b=&c2=&f3=&t3a=&v3a=&t3b=&v3b= |
I wonder if this is a bug or data is not available after August 31, 2021. I am trying to download data from 2011 to 2021 but I only get half of 2021. See my script below:
library(rnoaa)
create a data frame for Prince William latitude and longitude
lat_lon_df <- data.frame(id = "pw",
lat = 60.690545,
lon = -147.097055)
find 10 closest monitors to Prince William
mon_near_pw <-
meteo_nearby_stations(
lat_lon_df = lat_lon_df,
lat_colname = "lat",
lon_colname = "lon",
var = "PRCP",
year_min = 2011,
year_max = 2021,
limit = 20,
)
mon_near_pw
#3,9,11,14 Get rainfall data from Cannery Creek, Esther Island, Cordova, and Port San Juan
pw_prcp_dat <-
meteo_pull_monitors(
monitors = mon_near_pw$pw$id[c(1,3,11,14)],
date_min = "2011-01-01",
date_max = "2021-12-31",
var = "PRCP"
)
final <- pw_prcp_dat %>%
pivot_wider(names_from= id,values_from=prcp) %>% data.frame()
head(final)
dim(final)
#Rename stations with more meaningful names
names(final)[2:5] <- c("cannery_creek","esther_island","cordova_n","sanjuan_chenega")
head(final)
tail(final)
#Get the total rainfall of the sound
final$total_prcp <- rowSums(cbind(final$cannery_creek, final$esther_island, final$cordova_n,final$sanjuan_chenega),na.rm=T)
dim(final)
The text was updated successfully, but these errors were encountered: