Loading the Area Of Interest (AOI)
We start by loading in the spatial shape of the country we want to download data for. This helps us find out which tiles we need to download. We can also use this shape to directly synchronize the data without any manual steps, but this is up to the user. A visual representation of which tiles (10x10 degree blocks latitude/longitude in size) can be found here.
Loading the input vector dataset
A visual method to select the desired country
The code below can be loaded in Rstudio. It will open a window on which the user needs to click the country that we want to process to filter out the polygon of that country.
# Load the ForestForesight package
library(ForestForesight)
# Get the countries data and convert it to a spatial vector
countries <- vect(get(data("countries")))
# Open a new graphics device in full screen mode
x11(width=15,height=15)
# Plot all countries for which we have predictions
plot(countries)
# Allow the user to click on a country to select it
# n=1 means we're selecting just one country
country <- click(countries, n=1)
# Extract the shape of the selected country
# We use the ISO3 code to match the selected country
shape <- countries[countries$iso3 == country$iso3]
Loading a file from local disk as desired processing area
Alternatively, the user can load in their own data, either a ShapeFile, GeoJSON, KML/KMZ or other open vector data format. This can be done with the following lines. It will open an explorer window in which the file needs to be selected. The vector data will be converted to lat/long so it can be processed by the Forest Foresight package
# Load the ForestForesight package
library(ForestForesight)
#Load in a file from your local drive
shape <- vect(file.choose())
shape <- project(shape,"epsg:4326")
Â