Dear all,

 

 I am a R beginner and I want to draw maps with 2 layers. The lower one is defined by an adminstrative map with borders (for instance the US states borders and the US county border) and the upper layer is a contour plot (or a level plot) with artificial data or data coming from another large database.

The samples and the intervals of the (x-y) coordinates are not the same for the two layers. I would like to draw a map where the contour plot is only inside the borders of the bottom layer.

My codes are the following but I am not able to merge the two plots.

Any help is appreciated.

Thanks.

Georges Bresson

Université Paris II / Sorbonne Université
France

 


#--------- multiple layers with an administrative map with borders as the bottom layer

library(maps)
library(maptools)
library(RColorBrewer)
library(lattice)

# USA states data : "state" (x,y: long, lat)
# fig(1)
map("state", interior = TRUE)
map("county", boundary = FALSE, col="gray", lty = 1, add = TRUE) 
map("state", boundary = FALSE, col="black", add = TRUE, myborder=0.9) 
map.axes() 
map.scale(relwidth = 0.15, metric = FALSE, ratio = TRUE)

# fig(2) --- artificial data (axes : x, y )
x y r grid grid$z mypalette levelplot(z~x*y, grid, layers=1,col.regions=mypalette, cuts=90) 


# fig(3) ????
# 2 layers: 
#  - bottom layer : USA states and counties
#  - top layer: contour plot of artificial data (only inside the US states borders)



	[[alternative HTML version deleted]]

