[R-sig-Geo] map to shapefile with projection info

Sebastian P. Luque spluque at gmail.com
Wed Dec 6 18:44:11 CET 2006


Hi,

Trying to extract a map (package maps) to a shapefile, IIUC the procedure
is to get it into a SpatialPolygonsDataFrame and then use
writePolyShape().  This seems to require an intermediate step through
SpatialPolygons.  However, I'm running into some problems:


R> canada <- map("world2Hires", "Canada", plot=FALSE)
R> canada_sp <- map2SpatialPolygons(canada, IDs=canada$names,
+                                  proj4string=CRS("+proj=longlat +ellps=wgs84"))
Error in map2SpatialPolygons(canada, IDs = canada$names, proj4string = CRS("+proj=longlat +ellps=wgs84")) : 
	map and IDs differ in length


How can these two components be lined up?

I would also appreciate some suggestions on how to write a projection file
for the shapefile.  I can see this has been discussed in the past, but at
that time there was no solution.


Cheers,

-- 
Seb




More information about the R-sig-Geo mailing list