Skip to content
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

Extracting scattered date from several coordinates using ag5_extract #3

Open
nicolaycunha opened this issue May 23, 2023 · 0 comments

Comments

@nicolaycunha
Copy link

Hi there,

I recently came across this package and found it amazing.

I am able to download the AgERA5 data that I wanted to my computer and can extract single coordinates and locations, however, I am struggling to batch download climate data that are not sequential.

For instance, I can download data from scattered days using the below code:

library(ag5Tools)
ag5_download(variable = "2m_temperature",
             statistic = "day_time_mean",
             day = c(01,05,10,15,20,25),
             month = c(10, 11, 12, 01, 02, 03),
             year = 2015,
             path = "/Users/myfolder"
)

But when trying to extract such specific dates I got the obvious error message below, which I understand that I have not downloaded all the dates within the interval between the first and second dates, and the argument date seems to do not support non-sequential dates, as explained elsewhere :

If dates is one value it extracts a single observation for the specified variable and location. If dates is a character vector of length == 2, it will extract a time series of the specified variable and location, where the first dates value is the start date and the second the end date.

Please find here what I did the and error message.


# Create vectors for days, months, and year
days <- c(01, 05, 10, 15, 20, 25)
months <- c(10, 11, 12, 01, 02, 03)
year <- 2015

# Generate all possible combinations of days and months
all_dates <- expand.grid(days = days, months = months)

# Create a data.frame with the dates column
df <- data.frame(dates = as.character(paste(year, all_dates$months, all_dates$days, sep = "-")))

# sample coordinates
df_coord <- data.frame(lat = c(-20, -24), lon = c(-80, -90))

ag5_extract(coords = df_coord, 
            lon = "lon",
            lat = "lat",
            # dates = all , 
            variable = "Temperature-Air-2m",
            statistic = "Mean-Day-Time", 
            path = "/Users/nicolaycunha/Desktop/Kaoma2015",
            celsius = TRUE)


Error in ag5_extract.numeric(coords = c(35.726364, -2.197162), dates = 2015 -  :   object 'ag5_data' not found

In summary, I am reaching out to inquire whether it is possible to extract scattered dates from different coordinates within a row. My current project involves analyzing a vast dataset encompassing multiple locations in South America, and I specifically require data ranging from 1980 to 2023 for approximately 5000 specific coordinates. Unfortunately, I have encountered challenges in efficiently utilizing the available package to achieve my objectives.

Ideally, I would like to download climate data solely for the required coordinates and a subset of dates. This approach would alleviate the need to manage extensive datasets on a local computer, thus enhancing the overall efficiency of the analysis process.

I would greatly appreciate any advice or assistance you can provide in this regard. Please let me know if the current version of the functions supports such capabilities or if there are alternative approaches to achieve the desired outcome.

Thank you kindly for your attention and support.

Best regards,
Nicolay

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

No branches or pull requests

1 participant