I have MODIS data which contains 8 days product. Some of month has 3 images and some of month has four imgaes. So how I can build a R scrip to calculate monthly sum from this data
I am using the MODIS MOD17A2HGF GPP data set which comes as a 500x500 meter grid of the 8 day sum of GPP. The first file ends in _001 which means that it starts on January 1st and goes until the 8th. The next file, _009, then covers the 8th to the 16th of January and on and on. enter image description here
Now I want to sum GPP for months(January to December).
In this folder, it have 920 files (20 years) which every year has 46 files.
In ArcGIS, I know how to sum with raster calculator.But it will do so much repetitive works if I sum every month.
In R, I tried to do it just like this
library(terra)
a <- rast('MOD17A2HGF_GPP_2001_001.tif')
b <- rast('MOD17A2HGF_GPP_2001_009.tif')
c <- rast('MOD17A2HGF_GPP_2001_017.tif')
d <- rast('MOD17A2HGF_GPP_2001_025.tif')
GPP_January <- a+b+c+d
writeRaster(GPP_January,'F:/test/GPP_January_2001.tif')
It will also do so much repetitive works if I sum every month.I don't know how to select the specified files of month in R loop.
I know how to sum annual GPP
library(tidyverse)
library(terra)
GPP2001 <- list.files(pattern = '2001',full.names = T) %>%
rast() %>% sum()
But how can I sum monthly GPP per year in R or ArcGIS?