[STATSGRASS] Export ImageJ polygons to shapefile with R

Roger Bivand Roger.Bivand at nhh.no
Mon Oct 22 14:47:49 EDT 2007


On Mon, 22 Oct 2007, Bio7 wrote:

>
> Hello,
>
> in my application i use imageJ and have also integrated Rserve for the
> communication with R.
> What i like to do is to create a shapefile from multiple ImageJ selections
> (ROI's) with the help of
> Rserve which i can load then in Grass. At the moment i export the x,y
> coordinates for each
> polygon as a x list and y list (x0,y0 for the
> first selection, x1,y1 for the second selection etc.) to the workspace of R.
> My question is, how can i write a shapefile from this x-lists and y-lists?

One possibility is to create a list of Polygons objects, each with a 
single Polygon object with a matrix of coordinates (cbind(xi, yi) for i=0, 
n). See Polygons and SpatialPolygons documentation in the sp package. You 
can then write a SpatialPolygonsDataFrame as a shapefile with writeOGR() 
in rgdal or writePolyShape() in maptools.

Roger

>
> Any help is appreciated
>
> With kind regards
>
> Marcel
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the grass-stats mailing list