My goal is to reproject a raster called pftnc
to have the same CRS and cell size of another raster sp
, so they overlap perfectly and can be stacked. Files available here pftnc and sp
I thought it was an issue with software, see the other question https://gis.stackexchange.com/questions/299935/extract-values-from-raster-r-and-arcgis-different-results, but I am having inconsistencies just within R. So I would like to find an R solution first.
I have tried to reproject directly
pft1 <- projectRaster(pftnc, sp)
And also tried to first aggregate and then reproject
pftagg <- aggregate(pftnc, fact=4)
pftproj1 <- projectRaster(from=pftagg, to=sp)
I have also tried to just project and then crop and aggregate or the other way around but I can never get to the result I get when I use to=sp, so I abandoned this route. For example
cea=crs(sp)
pftproj2 <- projectRaster(pftnc, crs=cea)
The problem is that pftproj1 and pft1 have the same rows,columns,extent, and resolution but the values are different.
> cellStats(pftproj1,mean)
[1] 0.1955
> cellStats(pft1,mean)
[1] 0.2028
Is there a correct order of operations to achieve this goal? Should I let projectRaster deal with the aggregation of values? I imagine