[R-sig-Geo] mapping contours

Roger Bivand Roger.Bivand at nhh.no
Tue Nov 1 18:36:09 CET 2005


On Tue, 1 Nov 2005, Jeanne Thibeault wrote:

> I'm basically a beginner with R and would like to know the best and easiest
> way to add contour lines of climate data to a map. The data consists of
> points of longitude and latitude with one climate variable for each point. I
> was able to contour the data using akima, but that only provided me with a
> rectangular grid. I would appreciate any suggestions on how to add the
> contours to an existing map so that they fit appropriately.
> 

Assuming that you have a base map of some kind plotted already, you can 
use the add=TRUE argument to contour() to overplot with contours. There is 
no function in R to construct contours from irregularly placed points, you 
have to use interp() from tha akima package first (or some other 
interpolator - Tps in the fields package is a good alternative if you like 
splines), and go on from there.

If you need the actual lines, you can get them using contourLines(), and 
plot them afterwards - in contour(), they are never returned to the user. 
But to get contours, you need a regular grid first. If you need to, you 
can mask the regular grid with NA values, which contour() and 
contourLines() will respect.

Hope this helps,

Roger

PS.

Showing an informative excerpt of the code you've already tried may get 
you a more focussed response. Since this is climate data, the fields 
package may already have things you can use.

>  
> 
> Thanks,
> 
> Jeanne
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list