[R-sig-Geo] converting grid objects to spatial polygon objects and export as shapefile

mayeulk mayeul.kauffmann at free.fr
Fri Feb 5 01:22:24 CET 2010


Good evening,
I'm trying to do the same thing as discussed here:
https://stat.ethz.ch/pipermail/r-sig-geo/2009-December/007163.html
in my case to create kilometric UTM grid (graticule) as a shape file to
overlay on maps (in GIS software like QGIS) for GPS receiver use.

The above mentioned post does not give the end of the solution.
I tried this, without success (I also tried a few other CRS strings).
library(sp)
library(maptools)

scale.m<-1
#scale.m<-1000 #uncomment to define values in kilometers
grd <- GridTopology(cellcentre.offset=c(475000/scale.m,5078000/scale.m),
  cellsize=c(1000/scale.m,1000/scale.m), cells.dim=c(10,10))
grd2<-SpatialGrid(grid=grd, proj4string = CRS("+proj=utm +zone=32
+ellps=WGS84 +units=m +no_defs"))
spix <- as(grd2, "SpatialPixels")
spol <- as(spix, "SpatialPolygons") 
spdf <- SpatialPolygonsDataFrame(spol, data=data.frame(id=row.names(spol),
   row.names=row.names(spol))) 
plot(spdf)
writeSpatialShape(x=spdf,"~/Documents/randonnee/Italie/UTM_grid_R")


This create a set of shapefiles, but when I load it into qgis nothing is
dispayed and qgis complains about wrong scale.
Thanks for any hint
Mayeulk



-- 
View this message in context: http://n2.nabble.com/converting-grid-objects-to-spatial-polygon-objects-and-export-as-shapefile-tp4143331p4517330.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list