Skip to content
Tidy approaches with raster.
Branch: master
Clone or download
Latest commit 8f824cb Jun 5, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
R add rle pack/unpack Jun 5, 2019
data-raw oisst data set and projection by polygons with grid Aug 14, 2017
data oisst data set and projection by polygons with grid Aug 14, 2017
docs prepare for release Aug 9, 2018
inst pip cell Jan 23, 2018
man rebuild Aug 9, 2018
tests moar tests Aug 9, 2018
vignettes prep for release Dec 10, 2017
.Rbuildignore ignore Sep 28, 2017
.gitignore cells vignette May 22, 2017
.travis.yml travis Aug 5, 2017
DESCRIPTION prepare for release Aug 9, 2018
NAMESPACE some fixes May 21, 2018 prepare for release Aug 9, 2018
README.Rmd build docs May 21, 2018 build docs May 21, 2018
appveyor.yml scaffold Jul 7, 2017
codecov.yml r-gris org May 17, 2017 comments May 22, 2018
tabularaster.Rproj as_tibble Mar 29, 2017

Travis-CI Build Status AppVeyor build status Coverage Status CRAN_Status_Badge CRAN RStudio mirror downloads


The raster package is extremely powerful for spatial data. It provides very efficient data extraction and summary tools via consistent cell-index and comprehensive set of functions for working with grids, cells and their values.

Tabularaster provides some more helpers for working with cells and tries to fill some of the (very few!) gaps in raster functionality. When raster returns cell values of hierarchical objects it returns a hierarchical (list) of cells to match the input query, while tabularaster::cellnumbers instead returns a data frame of identifiers and cell numbers.

Tabularaster provides these functions.

  • as_tibble - convert to data frame with options for value column and cell, dimension and date indexing
  • cellnumbers - extract of cell index numbers as a simple data frame with “object ID” and “cell index”
  • index_extent - create an index extent, essentially extent(0, ncol(raster), 0, nrow(raster))

All functions that work with sp Spatial also work with `sf simple features.

There is some overlap with quadmesh and spex while I figure out where things belong.


Install from CRAN,


or get the development version from Github.



Basic usage is to extract the cell numbers from an object, where object is a a matrix of points, a Spatial object or a simple features sf object.

cells <- cellnumbers(raster, object)

The value in this approach is not for getting cell numbers per se, but for using those downstream. The cell number is an index into the raster that means the geometric hard work is done, so we can apply the index for subsequent extractions, grouping aggregations, or for determining the coordinates or other structure summaries of where the cell belongs.


## summarize by object grouping
cells %>% mutate(value= extract(raster, cell_)) %>% group_by(object_) %>% summarize(mean(value))

## summarize by cell grouping
cells %>% mutate(value= extract(raster, cell_)) %>% group_by(cell_) %>% summarize(mean(value))

The utility of this is very much dependent on individual workflow, so this in its own right is not very exciting. Tabularaster simply provides an easier way to create your tools.

See the vignettes for more.

You can’t perform that action at this time.