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

Karl Ove Hufthammer karl at huftis.org
Thu Oct 14 16:42:51 CEST 2010


Sean O'Riordain wrote:

> Thank you for that - some interesting ideas there.  While not a solution
> for you - I'm working on a similar problem and I've discovered
> mapserver(.org) for the display side of things.  It will handle rasters
> and shape files and display them quickly on a google map background.

Thanks for your ideas. My main worry about different projections is the 
statistical part, not the visualisation part. For example, an area with 
width w and height h in one projection (or as unprojected values) won’t 
have an actual area of (an constant times) w × h, and the actual area
varies with the latitude.

Using a UTM transformation *before* calculating anything mostly solves this 
problem. And having the same projection for the calculations and end map is 
also a good idea, since the reprojected data may be confusing (for example, 
why are the square grid now curved?).

Fortunately, the spTransform function makes reprojection of data in R very 
easy. The only problem I’ve had is with reprojections of actual maps (the 
output of the map function). Depending on the bounding box, I get a bunch of 
‘transformed point not finite’, and the projection fails. It’s not a very 
strange thing to happen, but very annoying.

The reason I get such problems, is that the unprojected map that I work with 
must have a (sometimes much) bigger bounding box than the area I’m actually 
interested in, since the projected first coordinate of the lower left corner 
of the unprojected bounding box is not equal to the projected first 
coordinate of the upper left corner of this bounding box. So to ensure that 
no countries/polygons go missing, you have to enlarge the bounding box, 
which may include areas so far north that the projection / spTransform can’t 
handle them (even though these areas wouldn’t be used on the final map.
I haven’t found a solution for this yet. :/

-- 
Karl Ove Hufthammer



More information about the R-sig-Geo mailing list