[R-sig-Geo] convert points into SHP polygons

Bjarke Christensen Bjarke.Christensen at sydbank.dk
Mon Nov 30 09:55:28 CET 2009


Jane (rusers.sh) wrote
>>>>>>  Does anybody know how to convert points to the SHP polygons?
>>>>>>  OR whether we can generate some SHP polygons randomly in R?
>>>>>> ##Example##
>>>>>> win<-owin(c(0,1),c(0,1))
>>>>>> pp <- runifpoint(10) #generate 10 points
>>>>>> #i want to change these 10 points into 10 SHP polygons,something
like

>>  What i want to get is the the class of SpatialPolygons(sp) based on the
>> generated Voronoi tessellation.
>>  Any ideas or suggestions are greatly appreciated.

Here is a quicker solution, (still using the spatstat library):
polys <- as(dirichlet(pp), 'SpatialPolygons')

dirichlet() gives you the Dirichlet/Voronoi tesselation, and as() coerces
it to SpatialPolygons, which can then be exported to a shapefile using
rgdal.

Bjarke Christensen



More information about the R-sig-Geo mailing list