title: How to perform 2D numerical integration over an arbitrary region given by function values at grid points in R?
body: <p>I would like to numerically evaluate an integral of the form:</p>
  <p>$$ int_D f(x,y) dx dy $$</p>
  <p>where $D$ is a region in $R^2$ and $f(x,y)$ is a map from $R^2$ to $R$.</p>
  <p>I have a grid covering a subset of $R^2$. From this grid, for my particular application, I  select a particular region $D$ (not necessarily rectangular, but simply-connected) according to the value of $f(x,y)$ (for example, I select all points for which $f(x,y) &lt; 5$).</p>
  <p>I would then like to integrate the function over this selected region. Many functions exist for 2D integrals over rectangular regions and some have been implemented for integration over simplicies. It appears to me none exist for integration over more general regions. It does not seem too complicated to implement a version of Riemann Sums, but have not seen it anywhere.</p>
  <p>Does anyone know?</p>