Sv: [R] Using locator() to digitise

From: Sixten Borg <sb_at_ihe.se>
Date: Mon 21 Mar 2005 - 20:05:57 EST


Hi,
Splus allows pasting a graphics object into the plotting window, which makes it possible to do what you describe below. Now I use R which doesn't seem to allow pasting the picture into the graphics window, so I copy the graph onto a transparency sheet, and stick it onto my screen using tape. The coordinates need to be converted to make sense (as you describe).

My methodology with the transparency has a "stoneage" appearance, but it works quite well, if I may say so myself.

I have written down some notes that describes what I did, but it's in Swedish so I guess it's not of much help.

Kind regards,
Sixten.

>>> Ted Harding <Ted.Harding@nessie.mcc.ac.uk> 2005-03-20 17:09 >>>
Hi Folks,

I'm contemplating using locator() to digitise external graphics. To set context, I would be using X11 display on Linux.

To pre-empt the obvious comment: I've found on the R site the suggestion to use the 'pixmap' package. I've tried this, and it works; but it involves building a big R object (the internal pixmap representation), and this chokes my somewhat puny laptop (e.g. it can take about 1 minute to draw the graphic inside a plot area using addlogo(), with mucho swappo, and subsequently working knee-deep in treacle). The following idea would be a lot slicker.

For examples: I have something like

  1. A scatterplot of data printed in a journal (but the data values are not available;
  2. A contour map (on paper) of a region.

So, I can scan the document, and obtain a file in some graphics format (jpeg, pbm or png, say).

Now: an idea which I find attractive is to be able to overlay an R plot with axes onto a display of the graphics file (produced as an X window by any suitable program such as 'xv' or 'display') so that (if the overlay were possible) clicking on the points of the graphic would in fact be clicking on the R plot and, via locator(), generate the R-plot coordinates of the mouse clicks which would correspond to the selected points on the graphic.

Provided the coordinate system of the R plot were properly related to the graphic, the results would be a digitisation of the selected points on the graphic.

What seems to be needed for this idea to work is that the R-plot should be displayed in an X11() device whose background was completely transparent, so that when moved over the (independently generated) display of the graphic the latter would be visible (but locator() would still be working on the R-plot itself). Window resizing could look after the correspondence between graphic coordinates and R-plot coordinates.

The R plot itself could be empty (apart from coordinate axes) or could contain "helper" elements such as grid lines, circles (e.g. I want to digitise graphics points within a certain circle), etc. "Helper" elements could be added to the R-plot by subsequent 'lines' or 'points' commands (e.g. I identify two points on the graphic, R-plot the line joining them, and then pick off graphic-points which lie on the R-line).

So this question is really about producing a "bare" R plot on, as it were, a virtual acrylic transparency. It's certainly possible to do such a thing in X: e.g. the cute "xteddy" is in fact a picture of a bear on a completely transparent rectangular background, though you'd never know by looking!

Any comments?

With thanks, and best wishes to all,
Ted.



E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861
Date: 20-Mar-05                                       Time: 16:09:11
------------------------------ XFMail ------------------------------

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Mar 21 20:11:49 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:51 EST