
Download GFW and CO2-Emission data
downloadGFW.Rd
This function downloads the necessary Global Forest Watch and CO2 Emission data for a given shapefile. The shapefile is transformed to its bounding box, projected to its central UTM Zone and a buffer is applied. The default buffer size is 5000 meteres, but it can be changes by the user. It uses gdal system calls to speed up the process. The raw files by default will be deleted, but they also can be kept on the disk. Note, the CO2 emission data is only available roughly between 30N and 30S and the function will fail if your input shapfiles extent plus buffer is extending beyond those limits. This function relies heavily on code published at https://github.com/azvoleff/gfcanalysis.
Arguments
- shape
A
sfObject
determining the extent for which to get the GFW data.- dataset
A
charachter
specifiying the version of the GFW data to extract. Defaults to version 1.6 from 2018. The newer version can be downloaded when you specifydataset = "GFW-2019-v1.7"
.- basename
A
charachter
which will be added to the resulting file names.- outdir
A
charachter
for a local directory for the final outputs. If it is not existing it will be created without a message. Defaults to the current working directory.- keepTmpFiles
A
logical
indicating if the raw tiles should be kept in thetmpdir
directory. It defaults toFALSE
, which usually makes sense. However, if you apply a number of analysis for different extents but there might be overlaps, it could be useful to keep the downloaded files on your machine. The function will only download the necessary data if it is not alread present in thetmpdir
.- .tmpdir
A
charachter
indicating a directory where to download the raw tiles to. It defaults to a random directory name in the actual R temporary directory. If you want to keep single values, e.g. when your aoi spans multiple tiles, you can specify a custom directory.
Value
A vector
of type charachter
with all the files matching
the basename
pattern in the outdir
directory.
Note
This function depends on available gdal binaries on your system. Make sure they are available as environment variables on your machine or use our docker image instead.
Author
Darius Görgen (MapTailor Geospatial Consulting GbR) info@maptailor.net
Maintainer: MAPME-Initiative contact@mapme-initiative.org
Contact Person: Dr. Johannes Schielein
Copyright: MAPME-Initiative
License: GPL-3
Examples
if (FALSE) {
aoi = st_read(system.file("extdata", "aoi_polys.gpkg", package = "mapme.forest"))
raster_files = downloadGFW(shape = aoi,
basename = "pkgTest",
outdir = "./data/",
keepTmpFiles = T,
.tmpdir = "./data/tmp")
# resulting rasters are not automatically cropped to the extent of aoi
rasters = stack(lapply(raster_files, function(f){
f = brick(f)
f = crop(f, aoi)
}))
}