View source: R/nightlight_download.R
| nightlight_download | R Documentation |
You can download DMSP nightlight data with this function. Note: the yearly DMSP data are of lower resolution than the monthly VIIRS data and takes up less space (1 year image for the whole world = 1/16 space of a monthly image for the whole world). Hence, yearly DMSP data will be fine on your normal drive (all years together ca. 45 GB incl. quality indicator files), but working with monthly VIIRS data likely requires an external drive (about 1.5+ TB for all files incl. quality indicator files). For some years, there are 2 DMSP versions available. The code downloads both. There are alternative data sources available, see the corrected_lights and harmonized_lights arguments for these.
nightlight_download(
area_names = "world",
time,
light_location,
shapefile_location = NULL,
shapefiles = NULL,
download_shape = ".gpkg",
gpkg_layer = NULL,
admlevel = 0,
user_coordinates = NULL,
corrected_lights = FALSE,
harmonized_lights = FALSE
)
area_names |
Default is "world", in which case data for the whole world will be downloaded (no difference for yearly data DMSP because there the whole world is one file; important for monthly data). This is a string (vector) with the name(s) of your region(s). If you provide a country name, the country shapefile will be downloaded automatically. Shapefiles in your shapefile location that have the area_names or (in case they exist) their iso3c countrycodes in their filename will be detected automatically. If you provide own shapefiles in the shapefiles argument, put the names in order of the shapefile order. If you only put one name for multiple shapefiles, all shapefiles will be processed with that name. |
time |
May not be empty. Vector of strings with the start/end dates in the format "2012-04" (monthly data) or "1992" (yearly data). If only one time period is desired, then simply input one date. |
light_location |
May not be empty. Provide the location where you store your light files on your drive as a string. |
shapefile_location |
May be empty. Provide the location of the shapefiles on your drive as a string in the case that you want to use shapefiles and not a set of coordinates. |
shapefiles |
May be empty. You can provide own shapefiles here (input are the filenames) if no automatic download is desired. If there is a shapefile in your shapfile location that has either the name of the region which you enter in area_names or the iso3c countrycode (if it is a country) in its filename, it will be detected automatically and you do not have to use this argument. |
download_shape |
Default is ".gpkg". Change to ".shp" or ".kml" if you want to download a different shapefile format from GADM. Will only download if no own shapefiles are provided in the shapefiles argument or automatically detected in the shapefile location. |
gpkg_layer |
May be empty. You might need this argument if the code does not detect the correct layer of a .gpkg file automatically. This can happen if the layers of your .gpkg shapefile do not include an admlevel in their names. In that case, enter the layer here as a string. Note that this only works for one area at a time. To find out which layers are included in your .gpkg shapefile, you can use sf::st_layers(). |
admlevel |
Default is 0. Change this when working with different administrative levels. |
user_coordinates |
May be empty. Inputs are decimal numbers (longlat). Can be specified if you want to download night lights for a region defined by specific coordinates. Input order is xmin, xmax, ymin, ymax. |
corrected_lights |
Default is FALSE. If set to TRUE, the radiance-calibrated version of the DMSP data will be downloaded. The data refer to the corrected lights by Bluhm and Krause (2022). |
harmonized_lights |
Default is FALSE. If set to TRUE, the harmonized DMSP-VIIRS yearly dataset by Li et al. (2020) will be used. Note that you have to download these versions first, since they are different images from the standard ones. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.