I recently found out about exactextract (and its R wrapper exactextractR). It is a tool for the extraction of zonal statistics from raster data, and it’s pure magic – it is incredibly fast and more accurate than other algorithms, as it considers partial coverage of pixels by polygons and weights the pixel values accordingly when aggregating them.
Another interesting tool that I always wanted to try out is plumber, an R package to easily create an API. So why not bring these tools together? I built a plumber API for a function that extracts zonal statistics from WorldPop population counts, based on geographic point coordinates and a buffer radius in meter. The geodesic buffer is created with geobuffer – another excellent tool.
I wrote a little Shiny app to interact with the API and to display the results on a Leaflet map. Meet pickPop!