I am trying to download and visualise the NDVI data in Kenya (and other countries similarly).
For this, I retrieved the bounding box for Kenya using osmdata
and used this when downloading NDVI data from MODIStsp
library(osmdata)
library(MODIStsp)
kenya_bb <- osmdata::getbb("Kenya")
MODIStsp(gui = FALSE,
out_folder = "Data",
out_folder_mod = "Data",
selprod = "Vegetation_Indexes_16Days_1Km (M*D13A2)",
bbox = kenya_bb,
bandsel = "NDVI",
user = "mstp_test" ,
password = "MSTP_test_01",
start_date = "2020.06.01",
end_date = "2020.06.15",
verbose = FALSE)
Then I simply visualised the downloaded data, but it hasn't seemed to crop out Kenya
library(raster)
library(here)
library(ggplot2)
NDVI_raster <- raster(here::here("Data/VI_16Days_1Km_v6/NDVI/MOD13A2_NDVI_2020_161.tif"))
NDVI_df <- as.data.frame(NDVI_raster, xy = TRUE, na.rm = TRUE)
rownames(NDVI_df) <- c()
ggplot(data = NDVI_df,
aes(x=x,y=y)) +
geom_raster(aes(fill = MOD13A2_NDVI_2020_161))
Any ideas on how to crop out single countries are appreciated