This repository stores functions written to download MODIS landcover data for coordinates across a range of years. Downloaded raw data can be quickly summarised into a .csv file so that raw ASCII files can be deleted, saving memory (and precious workspace!).
Please note that older versions of MODISTools
may have problems with broken links! It is therefore better to remove old versions first and install the most up-to-date version, i.e.
remove.packages('MODISTools')
followed by
install.packages("https://modis.ornl.gov/files/modissoapservice/MODISTools2.tar.gz",repos=NULL,type="source")
or manually downlaod MODISTools2.tar.gz here (https://modis.ornl.gov/data/modis_webservice.html) followed by
install.packages("yourfilepath/MODISTools2.tar.gz",repos=NULL,type="source")
test.dat <- data.frame(lat = c(-27.4678, -27.5636, -27.5598),
long = c(153.0067, 152.2800, 151.9507))
source("https://raw.githubusercontent.com/nicholasjclark/LandcoverMODIS/master/R/Landcover_functions.R")
!! but don't include 2010-2012, see below !!
This stores the raw downloaded data in a new 'LandCover' folder
download_landcover(years_gather = c(2006:2008), coordinates = test.dat)
!! Do not summarise before all necessary raw files are downloaded (raw files get deleted) !!
This writes a .csv summary file in the 'LandCover' folder and deletes the raw files
summarise_landcover()
I'm not sure why this is (maintenance on the satellite??), but they never seem to result in appropriate downloads. This should produce an error message:
download_landcover(years_gather = c(2008:2012), coordinates = test.dat)
For now, these years should just be omitted
I've included an error to remind that downloading for multiple subsets is safer. This should produce the error message:
error.dat <- data.frame(lat = rnorm(200, mean = 50),long = rnorm(200, mean = 50))
download_landcover(years_gather = c(2006:2008), coordinates = error.dat)
It is recommended to use subsets for sequential downloads i.e.
download_landcover(years_gather = c(2006:2008),
coordinates = test.dat[1:2,])
download_landcover(years_gather = c(2006:2008),
coordinates = test.dat[3:4,])
etc. to get all of the necessary raw data files. Once ALL of the subsets are downloaded, THEN use the summarise_landcover()
function
summarise_landcover()
These directions are also supplied in the Landcover_blueprint_test.R
file in the R
folder in case you would like to download the script and/or share it around. Please feel free to let me know if you run into issues!