I have encountered a problem with a difference in projecting some polygon data to EckertIV in ArcGIS Pro (version 2.6) and R (version 4.0.3). I am trying to calculate the number of raster cells within this polygon (New Zealand with it's EEZ). The data is available here: https://drive.google.com/drive/folders/1OE_q_W97KHw7iC3l0v9y5EMrYMSRLW_u?usp=sharing. In R, I load the data, project to Eckert IV using proj4 notation, and use raster::extract() to calculate the total sum of the pixels within the polygon.
Code:
library(raster)
library(sf)
poly <- st_read("data/stackoverflow/poly.shp")
poly <- st_transform(poly, crs = "+proj=eck4 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m no_defs")
cells <- raster("data/stackoverflow/cells.tif")
ex <- raster::extract(cells, poly, fun=sum, na.rm=TRUE, df=TRUE)
Using R, I get a value of 557 cells.
In ArcGIS, I add the data into a project, then I project the polygon data into EckertIV, and use zonal statistics as table. This results in 841 cells. If I use the projected polygon made in R, within ArcGIS, and use zonal statistics I get a value of 557, therefore indicating the projection is the problem.
I can visually see in ArcGIS that there is portion of the polygon projected in R that is missing compared to the polygon projected in ArcGIS. Can anyone explain why there is this difference and what I can do to ensure I get an accurate result in R? The portion of the polygon that is being missed is shown in pink