If you try to use sum()
directly in raster::aggregate()
and have NA
values, you’ll get NA
as a result. You need to build a tiny function and pass the rm.na=T
command to sum()
. More succintly:
# Dissolve duplicate geometries and sum OOIP fm <- raster::aggregate(fm.raw, by="OilFieldID", sums=list(list(function(x) sum(x,na.rm=T), "OOIP_pooltable")))