Hi, I want to make approximately 10000 square polygons (300*300) based on coordinates in a data frame, and make a .shp-file out of these.
The .pdf "S Classes and Methods for Spatial Data: the sp Package" by Pebesma and Bivand contains an instruction on how to do this, and it works very well, e.g. i=1 Sr1 = Polygon(cbind(c(dat[i,"X"]-150,dat[i,"X"] - 150,dat[i,"X"]+150,dat[i,"X"]+150,dat[i,"X"]-150), c(dat[i,"Y"]-150,dat[i,"Y"]+150,dat[i,"Y"]+150,dat[i,"Y"]-150,dat[i,"Y"]-150))) Srs1 = Polygons(list(Sr1),paste("Number.",i,sep="")) i=2 Sr2 = Polygon(cbind(c(dat[i,"X"]-150,dat[i,"X"] -150,dat[i,"X"]+150,dat[i,"X"]+150,dat[i,"X"]-150), c(dat[i,"Y"]-150,dat[i,"Y"]+150,dat[i,"Y"]+150,dat[i,"Y"]-150,dat[i,"Y"]-150))) Srs2 = Polygons(list(Sr2),paste("Number.",i,sep="")) SpP = SpatialPolygons(list(Srs1, Srs2), 1:2) SrDf = SpatialPolygonsDataFrame(SpP, dat[1:2,]) writePolyShape(SrDf, fn="TvaRutor") However, my data frame "dat" has ~10000 coords and want to write a loop for doing what is done above. My problem is how to store Sr1, Srs1, Sr2, Srs2,... Sr10000, Srs10000 etc to be used in SpatialPolygons(). Help on this is much appreciated. Cheers, Tord _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo