Skip to content
Back to formatted view

Raw Message

Message-ID: <5.2.1.1.0.20030630155905.01a44da8@biomserv.univ-lyon1.fr>
Date: 2003-06-30T14:14:48Z
From: Stéphane Dray
Subject: french map
In-Reply-To: <3F004762.8010301@avignon.inra.fr>

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(...,...)