我正在尝试下载和可视化肯尼亚(以及其他类似国家)的 NDVI 数据。
为此,我检索了肯尼亚使用的边界框,osmdata
并在从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)
然后我只是将下载的数据可视化,但似乎没有裁剪出肯尼亚
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))
任何关于如何裁剪单个国家的想法都值得赞赏