[R] french map

Stephane DRAY dray at biomserv.univ-lyon1.fr
Mon Jun 30 16:14:48 CEST 2003


At 16:21 30/06/2003, Peyrard Nathalie wrote:
>Hello,
>
>I would like to know if (as the usa map with Splus), it is possible with R 
>to plot the french map and to add points (representing towns for instance) 
>on the figure in the appropriate (x,y) system.
>Thank you.
>
>  Nathalie Peyrard


You can download the french map at 
http://www.ign.fr/affiche_rubrique.asp?rbr_id=810&lng_id=FR in shape files 
(ESRI) format and then use the library 'shapefiles' to load the map into R. 
I have write a small function to convert shapefiles into poly fomat. May be 
this function could be incorporated into Benjamin Stabler's package ?? 
Benjamin contact me if you are intersted.

Transform the shapefile into poly objects and then use the plotpolys 
function of the spdep package. Then you use graphical functions such as points

shape2poly <- function(shape) {
     nrecord <- length(shape$shp$shp)
     res <- list()
     id <- vector("character",nrecord)
     recta <- matrix(0,nrecord,4)
     for (i in 1:nrecord) {
         res <- c(res, list(as.matrix(shape$shp$shp[[i]]$points)))
         id [i]<- as.character(shape$dbf$dbf[i,1])
         recta[i,] <- as.vector(shape$shp$shp[[i]]$box)

     }

     attr(res, "region.id") <- id
     attr(res, "region.rect") <- recta
     class(res) <- "polylist"
     return(res)

}

myshp<-read.shapefile("'myshapefile")
polyeco<-shape2poly(myshp)
plotpolys(polyeco,attributes(polyeco)$region.rect)
points(...,...)




More information about the R-help mailing list