Download and Retrieve Nightlight Data
get_nightlight_data.Rd
This function downloads nightlight data from the Earth Observation Group's website. It scrapes the website to find and download the latest available nightlight data for the specified year and month.
Arguments
- year
A numeric or character year (e.g., 2020).
- month
A numeric or character month (1-12). This will be formatted as two digits.
- version
The version of the nightlight data (default is "v10").
- destination_dir
Directory to save the downloaded .tif file (default is current directory).
- timeout
Timeout in seconds for the download (default is 1200 seconds).
Details
The function constructs the appropriate URL for the specified year, month, and data version. It scrapes the directory listing on the website to find the latest available .tif file for the requested time period. The function then downloads this file and saves it to the specified directory. If no suitable file is found, or an error occurs, it returns NULL.
Examples
if (FALSE) { # \dontrun{
# Example: Download nightlight data for March 2021
file_path <- get_nightlight_data(2021, 3)
print(file_path)
} # }