# create binary raster
r <- raster::raster(nrows=108, ncols=108, xmn=-50, xmx=50)
raster::values(r)<- runif(n = (108*108))
r[r < 0.5] <- NA
r[r > 0.5] <- 1
# create shp
shp <- raster::raster(nrows=108, ncols=108, xmn=-50, xmx=50)
raster::values(shp)<- runif(n = (108*108))
# ratioOverlap
ratioOverlap(r = r, shp = shp)
Run the code above in your browser using DataLab