Let's say you have this data, just using a random set here for completeness,
SeedRandom[55];
(* A set of random 2D coordinates *)
list = RandomReal[100, {1000, 2}];
(* attach a set of less-random values as the third coordinate *)
list = {#1, #2, #1 + #2 + RandomReal[{-50, 50}]} & @@@ list;
You can view the data using a ListDensityPlot
or ListPlot
,
ListDensityPlot[list, ColorFunction -> "Rainbow"]
ListPlot[Style[{#1, #2}, ColorData["Rainbow"][#3/100]] & @@@ list,
AspectRatio -> 1,
GridLines -> {Range[0, 100, 20], Range[0, 100, 20]}]

You can see that the values generally get larger as x
and z
get larger, but that density plot is horrible.
To get a list of the values in a particular rectangular region, use Select
:
Last/@Select[list, 0 <= #[[1]] <= 20 && 0 <= #[[2]] <= 20 &]
(* {37.5551, 1.32275, 16.2364, 66.5277, 18.6801,......, 15.8541, 25.897, 33.8019, 19.1619} *)
And you can just use Mean
to get the mean value in that region (or Total
to get the total value).
Use Table
to collect all the mean values over, for example, a 5 by 5 grid,
{dx, dz} = {20, 20};
gridmean = Table[
Mean[
Last /@
Select[list, x <= #[[1]] <= x + dx && z <= #[[2]] <= z + dz &]
]
, {x, 0, 80, dx}, {z, 0, 80, dz}];
And then use ListDenistyPlot
to show the mean values,
ListDensityPlot[gridmean, ColorFunction -> "Rainbow",
InterpolationOrder -> 0, DataRange -> {{0, 100}, {0, 100}}]

Alternatively, you could create a list of Rectangle
objects and use RegionMember
to select the points,
regions =
Table[Rectangle[{x, z}, {x + dx, z + dz}], {x, 0, 80, dx}, {z, 0,
80, dz}];
gridmean = Table[
Mean[
Last /@ Select[list, RegionMember[regions[[n, m]], #[[;; 2]]] &]
], {n, 5}, {m, 5}]
But this is a bit slower