Skip to content

imaging and contouring

1 message · Nicolas Degallier

#
Dear R'Helpers and Colleagues,

I have looked in the documentation, asked to some colleagues in the  
lab, but was unable to solve the following difficulty.

I am running R on a  iMac  G5 with OS 10.4.

The file below (73 rows x 144 col) shows the values of a climatic  
index on the globe with a grid of 2,5 ?  x 2,5 ? (NA = no value):

?
With image() and map() and running the following function:

dessin_i<-function(nomfichier="ERA40NA.dat",lat=73,long=144) 
{ #d?finition de la fonction
library(maps)
a <- read.table(nomfichier) #lecture du fichier
z <- array(0,dim=c(long,lat)) #cr?ation d'un tableau de 0
z <- t(a) #transposition de la matrice a en z
z1<-rbind(z[65:long,],z[1:64,]) #centrage de la carte sur greenwich
nlat<-seq(-90,90,2.5) #d?finition des latitudes / ordonn?es de 2,5?  
en 2,5?
nlong <- seq(-180,177.5,2.5) #d?finition des longitudes /abcisses de  
2,5? en 2,5?
image(nlong,nlat,z1,col=rainbow 
(100),xlab="longitude",ylab="latitude") #tra?age
map(add=TRUE) #superposition de la carte des continents et pays
}

And then:
 >dessin_i()

I got the following figure (anonymous ftp):

ftp://ftp.lodyc.jussieu.fr/ndelod/ND_Fig1.pdf

running the following:

dessin_c<-function(nomfichier="ERA40NA.dat",lat=73,long=144) 
{ #d?finition de la fonction
library(maps) #chargement du package maps
a <- read.table(nomfichier) #lecture des donn?es
z <- array(0,dim=c(long,lat)) #cr?ation d'un tableau de 0
z <- t(a) #transposition de la matrice a en z
z1<-rbind(z[65:long,],z[1:64,]) #centrage de la carte sur greenwich
nlat<-seq(-90,90,2.5) #d?finition des latitudes / ordonn?es de 2,5?  
en 2,5?
nlong <- seq(-180,177.5,2.5) #d?finition des longitudes /abcisses de  
2,5? en 2,5?
contour(nlong,nlat,z1,col=rainbow 
(100),xlab="longitude",ylab="latitude") #tra?age
map(add=TRUE) #superposition de la carte des continents et pays
}

and:
 >dessin_c()

I got the following figure (anonymous ftp):

ftp://ftp.lodyc.jussieu.fr/ndelod/ND_Fig2.pdf

Finally, running:

dessin_f<-function(nomfichier="ERA40NA.dat",lat=73,long=144) 
{ #d?finition de la fonction
library(maps) #chargement du package maps
a <- read.table(nomfichier) #lecture des donn?es
z <- array(0,dim=c(long,lat)) #cr?ation d'un tableau de 0
z <- t(a) #transposition de la matrice a en z
z1<-rbind(z[65:long,],z[1:64,]) #centrage de la carte sur greenwich
nlat<-seq(-90,90,2.5) #d?finition des latitudes / ordonn?es de 2,5?  
en 2,5?
nlong <- seq(-180,177.5,2.5) #d?finition des longitudes /abcisses de  
2,5? en 2,5?
filled.contour(nlong,nlat,z1,col=rainbow 
(100),xlab="longitude",ylab="latitude") #tra?age
map(add=TRUE) #superposition de la carte des continents et pays
}

and:
 >dessin_f()

I got the following figure (anonymous ftp):

ftp://ftp.lodyc.jussieu.fr/ndelod/ND_Fig3.pdf

It may be similar to what I am looking for, i.e. the first figure  
with smoothed contours and a scale of the colors/values but I have  
been unable (or didn't found the right options) to put the map in the  
right place.

Is it possible and how to do it:
1)  to use "filled.contour()" without the scale?
2) to put again the map and the coloured contours adjusted?
3) to obtain the colours of the first figure with "filled.contour"  
function?

A subsidiary question is yet: how to obtain levels lines thicker and/ 
or in other colour only for specified values of z1?

Many thanks in advance.

Sincerely,

Nicolas Degallier

UMR 7159 / IRD UR182
Laboratoire d'Oc?anographie et du Climat, Exp?rimentation et  
Approches Num?riques (LOCEAN)
Tour 45-55, 4e ?t., case 100, 4 place Jussieu
75252  Paris Cedex 5  France
t?l: (33) 01 44 27 51 57
fax: (33) 01 44 27 38 05

E-mail: <Nicolas.Degallier at ird.fr>
pdf reprints (anonymous ftp): ftp://ftp.lodyc.jussieu.fr/ndelod