I am trying to use the MODIStsp package to download MODIS data and convert it in a usable format (R table) to do statistical analysis. I downloaded the data, and loaded the virtual raster file in my R session :
library(sp)
library(MODIStsp)
# loading virtual file
virtual_file = "C:/Users/hp-8570w/Desktop/internship/MODIS_data/output/Surf_Temp_Daily_1Km_v6/Time_Series/RData/Terra/LST_Day_1km/MOD11A1.RData"
data = get(load(virtual_file))
And now I am trying to extract data at some specific points. For that, I have a set of points (latitudes and longitudes) stored in a dataframe with 2 columns. I create a SpatialPoints object :
points = read.csv('points.csv',sep = " ")
projection = CRS('+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181+b=6371007.181 +units=m +no_defs')
spatial_points = SpatialPoints(points, proj4string = projection)
And I want to use the MODIStsp_extract() function :
test_extract = MODIStsp_extract(data,spatial_points)
I get the following error message :
Error in MODIStsp_extract(raster_ts, spatial_points) :
no slot of name "data" for this object of class "SpatialPoints"
As the documentation shows (https://www.rdocumentation.org/packages/sp/versions/1.3-1/topics/SpatialPoints), SpatialPoints objects do not have a "data" field, but SpatialPointsDataFrame do. However, the data slot is intended for flat tables, with some data for every line, every line being a point. What I don't get is that I obviously don't have this data for every point : that's what I am trying to recover from the raster in the first place ! So obviously there is something I am doing wrong, but I can't see what.
If anoybody has any idea what I am doing wrong, that would be of great help !