I'm trying to use the MODIStsp
R package to download data for a defined country. For this I downloaded the boundary of Mongolia from here into my working directory and passed it's path into my MODIStsp()
function. However, this doesn't seem to download the data within the defined boundary and keeps downloading the initial example
spatial_file <- "C:/Users/Zstar/mongolia_administrative_boundaries_national_polygon.shp"
MODIStsp(gui = FALSE,
out_folder = "Data",
out_folder_mod = "Data",
selprod = "Vegetation_Indexes_16Days_1Km (M*D13A2)",
spafile = spatial_file,
bandsel = "NDVI",
quality_bandsel = "QA_usef",
indexes_bandsel = "SR",
user = "mstp_test" ,
password = "MSTP_test_01",
start_date = "2020.06.01",
end_date = "2020.06.15",
verbose = FALSE)
library(raster)
library(here)
library(ggplot2)
raster <- raster(here("Data/VI_16Days_1Km_v6/NDVI/MOD13A2_NDVI_2020_161.tif"))
df <- as.data.frame(raster, xy = TRUE, na.rm = TRUE)
ggplot(data = df,
aes(x=x,y=y)) +
geom_raster(aes(fill = MOD13A2_NDVI_2020_161))
The default value of argument
spatmeth
is"tiles"
, so values specified with argumentsstart_x
,end_x
,start_y
andend_y
(and, if not explicitly specified, their defaults) are used, unlessspatmeth = "file"
is explicited.From the function documentation:
Adding
spatmeth = "file"
toMODIStsp()
should solve.