spex

Spex provides a small set of functions for working with spatial data. These are

  • spex() - a spatial extent with projection metadata
  • polygonize() - a fast quadmesh-based pixel-to-polygon translation
  • buffer_extent - a convenience function for tidy extents
  • xlim, ylim - convenience functions for the axes of an extent
  • extent() - convenience functions for sf objects
  • latmask() - mask a raster based on a latitude
  • latitudecircle() - create a spatial region based on a latitude

Create a fully-fledged SpatialPolygonsDataFrame extent from any object understood by the ‘raster’ package function ‘extent()’. If the input has projection metadata it will be carried through to the output. The intention is to support any object from packages sp, raster and sf. If you want this to work on other types, create an issue and get in touch to discuss!.

The polygonization approach is faster than rasterToPolygons, and multi-layer rasters are converted to multi-column spatial data frames. This only does the pixel-to-polygon case. It provides an sf POLYGON data frame, but there is a version qm_rasterToPolygons_sp that returns a Spatial version.

The “buffered extent” is used to create cleanly aligned extents, useful for generating exacting grid structures as raster or vector.

Installation

Install ‘spex’ from CRAN.

Examples

Create a Spatial object as a single extent polygon from a raster.

Create a simple features POLYGON data frame from a raster.

Create a buffered extent with whole-number aligned edges.

There are convenience functions for sf objects.


Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.