Skip to content
Prev 33999 / 398506 Next

french map

At 16:21 30/06/2003, Peyrard Nathalie wrote:
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(...,...)