velox is an R package for performing fast extraction and manipulation operations on geospatial raster data. velox is fast because:
velox is fully interoperable with the raster, sp, and sf packages.
r require(badger); badge_devel("hunzikp/velox", "green")
``` {r, echo = FALSE, warning = FALSE, message = FALSE}
library(velox) library(sf) library(raster) library(rasterVis)
nl.vx <- velox('nl.tif') sui.sf <- readRDS(file = 'sui.Rda')
vx.time <- system.time(ex.mat <- nl.vx$extract(sp = sui.sf, fun = function(x) sum(x, na.rm = TRUE)))
sui.sp <- as(st_zm(sui.sf), 'Spatial')
ras.time <- c(0,0,54.759)
``` {r, echo = FALSE, warning = FALSE, message = FALSE, fig.height = 2.75, fig.width = 4.5} ## Plot nightlights lattice.options(axis.padding=list(factor=0.5)) nightPalette <- colorRampPalette(c("black", rgb(4,6,84, maxColorValue=255), rgb(218,165,32, maxColorValue=255), "white"), bias = 0.95) par(mar = c(0,0,0,0)) image(log(nl.vx$as.RasterLayer()), col = nightPalette(25), axes = FALSE)
## Plot geometries ar <- st_area(st_zm(sui.sf)) lnl <- log(as.vector(ex.mat)/as.vector(ar)) # Log nl per area nightPalette <- colorRampPalette(c(rgb(4,6,84, maxColorValue=255), rgb(218,165,32, maxColorValue=255), "white"), bias = 1) col <- nightPalette(25)[as.numeric(cut(lnl, breaks = 25))] par(bg = grey(0.25), mar = rep(0, 4), xaxs = "i", yaxs = "i") plot(sui.sp, col = col, border = grey(0.1), lwd = 0.1)
Aggregating September 2017 nightlight emissions for 2268 Swiss communes takes r round(vx.time[3], 2)
seconds in velox and r round(ras.time[3], 2)
seconds in raster.
velox currently offers the following features:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.