Re: computing the area inside a contour plot

• To: mathgroup at smc.vnet.net
• Subject: [mg57622] Re: [mg57580] computing the area inside a contour plot
• From: Selwyn Hollis <sh2.7183 at earthlink.net>
• Date: Thu, 2 Jun 2005 05:17:00 -0400 (EDT)
• References: <200506011003.GAA24462@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Jun 1, 2005, at 6:03 AM, I. I. wrote:

> hi,
>
> I have a plot of data points on a set of x and y coordinate axes.
> These data points form a contour (it sort of looks like a "blob" of
> points).  I would like to compute the area inside this contour
> using Mathematica.  Any help would be really appreciated.
>
> Thank you,
>
> I. I.

You can do this with a discrete version of Green's theorem, which in
the continuous case says that

area = 1/2 Integral of  x dy - y dx around the boundary

Here's an example of how this can be used to get an approximate area
in the discrete case:

(*This computes points along the unit circle (note that the first and
last points are the same). *)

pts = Table[{Cos[t], Sin[t]}, {t, 0., 2*Pi, Pi/100}];

(*Now transpose to get separate lists of x and y coordinates.*)

transpts = Transpose[pts];

(*Compute differences to obtain "dx" and "dy" values.*)

diffs = ListCorrelate[{1,-1},#1]& /@ transpts ;

(*Compute sums as dot products.*)

.5*( Rest[Last[transpts]].First[diffs] - Rest[First
[transpts]].Last[diffs])

(* This gives 3.14108, a decent approximation of Pi. *)

--------------
Selwyn Hollis
http://www.appliedsymbols.com

```

• Prev by Date: Re: mml files
• Next by Date: Re: Re: Limit of list
• Previous by thread: computing the area inside a contour plot
• Next by thread: Re: computing the area inside a contour plot