[R] Points to spatial polygons

Adrian Antonescu bogdan.antonescu at manchester.ac.uk
Fri Feb 28 19:38:01 CET 2014


Hi All, 

With the risk of asking an obvious question: I have use the following code to generate hexagonal tessellation:

lambertCRS<-"+proj=laea"
coords1<-matrix(c(-30,31,-30,80,50,80,50,31,-30,31),ncol=2, byrow=TRUE)
coords=project(coords1,lambertCRS)
pg=Polygon(coords)
HexPts=spsample(pg, type="hexagonal", n=1750, offset=c(0,0),border=FALSE) 
HexPols = HexPoints2SpatialPolygons(HexPts) 
proj4string(HexPols)<-lambertCRS 
baseCRS<-CRS("+proj=longlat +ellps=WGS84")
HexPolsLatLon<-spTransform(HexPols,baseCRS)

What I am trying to do next is to generate the same tessellation but using squares instead of hexagons. This can be achieved by using: spsample(pg, type="regular", n=1750, offset=c(0,0),border=FALSE)
but I do not know how to convert the resulting points to spatial polygons.

Thank you very much.

Cheers,
Bogdan


More information about the R-help mailing list