My goal is to extract values from the raster called pftnc
by using the other raster sp
after converting it to a point shapefile. Files available here pftnc and sp
I have two raster files
pftnc=raster("pftnc.tif")
sp=raster("sp.tif")
sp
class : RasterLayer
dimensions : 142, 360, 51120 (nrow, ncol, ncell)
resolution : 96486, 96515 (x, y)
extent : -17367529, 17367529, -6356742, 7348382 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
names : Puma_concolor
values : 0, 1 (min, max)
pftnc
class : RasterLayer
dimensions : 720, 1440, 1036800 (nrow, ncol, ncell)
resolution : 0.25, 0.25 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
value : 0,1
In R, first I use aggregate to upscale one to have the same dimensions, I crop and then I project.
pftagg <- aggregate(pftnc, fact=4)
pftext <- c(xmin= -180, xmax= 180, ymin= -60, ymax= 90)
pftagg=crop(pftagg,pftext)
pft1 <- projectRaster(pftagg, sp)
Then I convert raster to points and extract the values
sppoints=rasterToPoints(sp,fun=function(x){x==1})
result=extract(pft1,sppoints[,1:2])
I do the equivalent operations in ArcGIS 10.5, but I don't reproject or crop because when I import the layers everything lines up perfectly.
So the problem now is that I have inconsistencies between the two methods. Aside from a few missing points from the ArcGIS operation, I get slightly different means and standard deviation. I also tried to import in ArcGIS the raster after cropping, aggregating, etc, and I still get these differences. So things in ArcGIS are at least consistent with itself. I am wondering if these small differences are due to how the two software are dealing with projecting the latlong raster to CEA projection.