Cross-posted to the velox GitHub repo: https://github.com/hunzikp/velox/issues/40
I'm able to extract average tree cover values for each of the three small counties in the US State of Delaware, but I don't seem to have enough CPU or RAM to do the same thing for all counties in the US.
I'm getting my tree cover data from https://prd-tnm.s3.amazonaws.com/StagedProducts/Small-scale/data/LandCover/tree48i0100a.tif_nt00840.tar.gz. See also https://www.sciencebase.gov/catalog/item/581d0548e4b08da350d52653
library(raster) library(tigris) tigris.state.counties <- counties(state = 10) tree.raster <- raster("tree48i0100a.tif") polygon.trees <- extract(tree.raster, tigris.state.counties, fun = mean, na.rm = TRUE) report <- cbind.data.frame(tigris.state.counties$NAME, polygon.trees) print(report) tigris.state.counties$NAME polygon.trees 1 New Castle 70.75920 2 Sussex 68.17089 3 Kent 67.00225
So I have set up an R environment on a 64 GB AWS instance, and I'm trying to take advantage of the
velox fast extraction. But all of the values I extract are
What am I doing wrong?
UPDATE: I still get NAs even if I use the small polygon option
FWIW, I was able to replicate the velox extract tutorial and even modify it to get the night light intensity in the Delaware counties.
My attempt to extract tree cover in Delaware counties with velox:
library(velox) library(tigris) tree.velox <- velox("tree48i0100a.tif") tigris.state.counties <- counties(state = 10) tree.mean.mat <- tree.velox$extract( sp = tigris.state.counties, fun = function(x) mean(x, na.rm = TRUE) ) report <- cbind.data.frame(tigris.state.counties$NAME, tree.mean.mat) print(report) tigris.state.counties$NAME tree.mean.mat 591 New Castle NA 1150 Sussex NA 2861 Kent NA