The R package polyCub implements cubature (numerical integration) over polygonal domains. It solves the problem of integrating a continuously differentiable function f(x,y) over simple closed polygons.
You can install polyCub from CRAN via:
To install the development version from the GitHub repository, use:
## install.packages("remotes") remotes::install_github("bastistician/polyCub")
The basic usage is:
library("polyCub") polyCub(polyregion, f)
polyregion represents the integration domain as an object of class
"owin" (from spatstat.geom),
"gpc.poly" (from gpclib or rgeos),
"SpatialPolygons" (from sp), or
"(MULTI)POLYGON" (from sf),
or even as a plain list of lists of vertex coordinates (
f is the integrand and needs to take a two-column coordinate matrix
as its first argument.
polyCub() function by default calls
a C-implementation of product Gauss cubature.
The various implemented cubature methods can also be called directly.
Simple two-dimensional midpoint rule based on
Adaptive cubature for radially symmetric functions
integrate() along the polygon boundary
(Meyer and Held, 2014, The Annals of Applied Statistics,
https://doi.org/10.1214/14-AOAS743, Supplement B, Section 2.4)
Accurate (but slow) integration of the bivariate Gaussian density
based on polygon triangulation and
For details and illustrations see the
in the installed package or
The polyCub package evolved from the need to integrate so-called spatial interaction functions (Gaussian or power-law kernels) over the observation region of a spatio-temporal point process. Such epidemic models are implemented in surveillance.
Contributions are welcome!
Please submit suggestions or report bugs at
or via e-mail to
The polyCub package is free and open source software, licensed under the GPLv2.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.