My project is on sheep in California and I'm trying to get the vegetation measures of the region over time to see if there's any correlation between disease prevalence and increased vegitation (measured as NDVI). To do this I found a website that went through how to use MODIStsp: https://flograttarola.com/post/modis-downloads/. I have coordinates for the presence of disease but I need the NDVI data.
I am trying to get the NDVI data for California (shapefile downloaded from here: https://data.ca.gov/dataset/ca-geographic-boundaries) into R using the MODIStsp package and inputting my conditions below:
#Not all of these packages are necessary but I have included those that I have tried. The necessary code has stars (**) highlighting it:
**install.packages("MODIStsp")**
**library(MODIStsp)**
**install.packages('terra')**
**library("terra")**
**library(sf)**
**library(tidyverse)**
install.packages("gdalUtils")
library(gdalUtils)
install.packages('rgdal', type='source')
library(rgdal)
library(raster)
library(here)
library(ggplot2)
install.packages("hdf4r")
library("hdf4r")
**spatial_file <-("~/Downloads/ca-state-boundary/CA_State_TIGER2016.shp")**
**MODIStsp(gui = FALSE,
out_folder = "Downloads", #Where I want to store my data
out_folder_mod = "Downloads",
selprod = 'Vegetation Indexes_16Days_250m (M*D13Q1)',
sensor = 'Terra',
bandsel = 'NDVI', #Get NDVI data
spatmeth = 'file',
spafile = spatial_file, #Spatial file of California
indexes_bandsel = "SR",
user = 'EXAMPLE', # your username for NASA http server
password = 'EXAMPLE', # your password for NASA http server
start_date = '2000.01.01',
end_date = '2022.12.31',
verbose = TRUE,
out_format = 'GTiff',
compress = 'LZW',
out_projsel = 'User Defined',
output_proj = '+proj=latlong +datum=WGS84 +units=m +no_defs', #I want to get the NDVI data for coordinates
delete_hdf = TRUE, #Delete hdf files after making them into GTiff
parallel = TRUE
)**
But I keep running into the same error:
<
Error in gdal_utils("buildvrt", gdalfile, output.vrt, opts) :
gdal_utils buildvrt: an error occured
In addition: Warning messages:
1: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Error 4: `Downloads/MOD13Q1.A2000049.h08v04.006.2015136104517.hdf' not recognized as a supported file format.
2: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Message 1: Can't open Downloads/MOD13Q1.A2000049.h08v04.006.2015136104517.hdf. Skipping it
3: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Error 4: `Downloads/MOD13Q1.A2000049.h09v04.006.2015136104603.hdf' not recognized as a supported file format.
4: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Message 1: Can't open Downloads/MOD13Q1.A2000049.h09v04.006.2015136104603.hdf. Skipping it
5: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Error 4: `Downloads/MOD13Q1.A2000049.h07v05.006.2015136104501.hdf' not recognized as a supported file format.
6: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Message 1: Can't open Downloads/MOD13Q1.A2000049.h07v05.006.2015136104501.hdf. Skipping it
7: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Error 4: `Downloads/MOD13Q1.A2000049.h08v05.006.2015136104621.hdf' not recognized as a supported file format.
8: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Message 1: Can't open Downloads/MOD13Q1.A2000049.h08v05.006.2015136104621.hdf. Skipping it
9: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Error 4: `Downloads/MOD13Q1.A2000049.h09v05.006.2015136104623.hdf' not recognized as a supported file format.
10: In CPL_gdalbuildvrt(source, destination, options, oo) :
GDAL Message 1: Can't open Downloads/MOD13Q1.A2000049.h09v05.006.2015136104623.hdf. Skipping it
>
If anyone could help me solve this, I'd be very grateful!