View source: R/get_precipitation_data.R
get_precipitation_data | R Documentation |
get_precipitation_data
connects to the EpiGraphHub database to pull an spatial polygon from a country and an specific administrative level. Then, it connects to the Google Earth Engine database to pull a dataframe containing daily precipitation data for the study area. This function pulls data from CHIRPS (Rainfall Estimates from Rain Gauge and Satellite Observations) using the rgee package..
get_precipitation_data( x, id_col = NULL, country = NULL, admin_lvl = NULL, startDate, endDate )
x |
an |
id_col |
if providing a sf object, please specify what is the id column that uniquely specifies each of the spatial objects, such as districts, regions, cities, etc. |
country |
a three-letter string specifying the country iso code (ISO 3166-1 alfa-3) pull data from. Must be "1", "2" or "3". Please, check https://gadm.org/ for available countries and administrative levels. |
admin_lvl |
a string specifying the administrative level to pull data from. Must be "1", "2" or "3". Please, check https://gadm.org/ for available countries and administrative levels. |
startDate |
a string containing the starting date in "yyyy-mm-dd" format for the query. |
endDate |
a string containing the ending date in "yyyy-mm-dd" format for the query. |
To read more about CHIRPS: #' https://www.chc.ucsb.edu/data/chirps https://www.nature.com/articles/sdata201566
To read more about R Google Earth Engine https://cran.r-project.org/web/packages/rgee/
A Internet connection is needed to use this function. Longer time periods and large datasets can take several minutes to fetch data, especially if using a free account. Adjust expectations accordingly.
This functions calls the rgee package. If you never used rgee, please follow the instalation instructions. You will be prompted to create an user account on Google Earth Engine or to connect to an existing one. This is mandatory for rgee to run. Please, go to https://cran.r-project.org/web/packages/rgee/ for more instructions.
## Not run: library(epigraphhub) country = "AGO" admin_lvl = "2" startDate = "2021-01-01" endDate = "2022-01-01" con <- egh_connection(auto_connect = TRUE, use_env = TRUE, path_env = ".env") df <- get_precipitation_data(x = con, country = country, admin_lvl = admin_lvl, startDate = startDate, endDate = endDate) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.