[R-sig-Geo] Creating density heatmaps for geographical data

Karl Ove Hufthammer karl at huftis.org
Thu Oct 14 14:56:46 CEST 2010


Karl Ove Hufthammer wrote:

> However, since the ‘heatmap’ is really a density estimate, it integrates
> to 1. I would instead want the heatmap colours to correspond to real
> frequencies (of course, they do, but the actual mapping is not visible on
> the colour scale).

I have been thinking a bit more on this, and what I really need is having 
the value at a point correspond to the *sum* of the weights close to the 
points (e.g., in a 1 km radius).

An example:

x=c(.2, .25, .8)
y=c(.75, .7, .2)

If all the points have unit weight, the output value at the two points at 
the top-left corner should be 2, and the value at the bottom right corner 
should be 1. If we have weights

w=c(10, 10, 20)

the output value should be 20 near both point clusters, 10 in areas only 
close to *one* of the points in the top-left clusters, and 0 everywhere 
else.

A couple of real-life examples:

1. The weights being housing prices, and the output being the money earned
   by selling all the houses in an area (a circle centred at the output
   point).
2. The weights being the quantity (number or weight) of fish caught at
   different locations, and the output being the total amount caught in
   an area.

I could of course set up a grid for this, and simply calculate the sum of 
weights in each grid cell, but I would prefer using distance from the centre 
of each cell to select which observations to count. And using some sort of 
kernel smoothing sounds like a good idea, at least in theory. But the (lack 
of) a normalizing constant makes the solution non-obvious (for me). And 
computational issues when there are many observations may of course also be 
a problem. I feel there must already be an R function/package written for 
just this type of calculation. :)

So, any ideas?

-- 
Karl Ove Hufthammer



More information about the R-sig-Geo mailing list