Export ImageJ polygons to shapefile with R

3 messages Options
Embed this post
Permalink
Bio7

Export ImageJ polygons to shapefile with R

Reply Threaded More More options
Print post
Permalink
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?

Any help is appreciated

With kind regards

Marcel
Roger Bivand

Re: Export ImageJ polygons to shapefile with R

Reply Threaded More More options
Print post
Permalink
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: [hidden email]

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
Bio7

Re: Export ImageJ polygons to shapefile with R

Reply Threaded More More options
Print post
Permalink
Thanks for the reply!

I've managed to create SpatialPolygons with the help of your "sp" script and could plot
them.

With kind regards

Marcel