
Download 1km DEM Raster for Multiple Countries and Save to Files
Source:R/download_country_DEM.R
download_country_DEM.RdThis function downloads 1km resolution DEM (Digital Elevation Model) raster data for a given vector of ISO3 country codes, and writes each raster to a GeoTIFF file.
Arguments
- PATHS
A list containing paths where DEM data will be saved. Typically generated by the
get_paths()function and should include:DATA_DEM: Path to the directory where DEM rasters will be saved.
- iso_codes
A character vector of ISO3 country codes for which DEM data should be downloaded.
- zoom_level
An integer representing the zoom level for the DEM data. Zoom levels 6-8 are recommended for 1km resolution (default = 6).
- overwrite
If
FALSE(default), a country whose DEM file already exists is skipped;TRUEre-downloads and replaces it.
Value
Invisibly, the paths of the DEM files that exist after the call. Each is written atomically (temporary file, then rename), so a failed or interrupted download never replaces a good raster.
Details
Terrain does not change between refreshes, and PATHS$DATA_DEM lives under
MOSAIC-data/raw/, so existing rasters are never rewritten unless overwrite = TRUE. Each
download appends a row to PATHS$DATA_DEM/PROVENANCE.md. File names stay undated because
get_elevation() reads <ISO>_1km_DEM.tif.