I have multiple rasters files and a grid shapefile.
I load the shapefile:
grid = st_read('/grid.shp')
I load the raster and create a raster stack
`path <- "/VI_tif"` #folder where I have stored the raster data
dlist <- dir(path,pattern="VCI.tif")
for (i in 1:length(dlist)) {
fold <- paste(path,dlist[i],sep="/")
fls <- dir(fold,pattern="VCI.tif")
flsp <-paste(fold,fls,sep="/")
vcistack <- stack(flsp)
Then, I extract the variable from the vcistack according to my grid shapefile:
vci.grid <- exact_extract(vcistack, grid, include_cols=T, include_xy=T, force_df=T)
Finally, I want to transform the list into dataframe:
vci.grid.df <- rbindlist(vci.grid, fill=T, use.names = T)
However, I got the following error message:
Error in rbindlist(vci.grid, fill = T, use.names = T) :
Column 1 of item 1 is length 225 inconsistent with column 9 which is length 50625. Only length-1 columns are recycled
Which I don't understand because when I look at it there are 225 rows, not 50625.
Any ideas how to solve this?