[R-sig-Geo] rasterImage support in R > 2.11.0 (problem for Windows in SDI mode)

Michael Sumner mdsumner at gmail.com
Tue Jul 20 10:59:24 CEST 2010

Hello, this is just a note for new raster plotting support - and only
affects users of R for Windows in SDI mode (window application mode-
which is not the default install option).  It affects both 32- and
64-bit R on Windows.

The behaviour is a bit weird and subtle, so this should only be of
interest to Windows users in SDI, and only for the interactive default
windows() device as far as I can tell.

image.SpatialGridDataFrame now uses the base graphics function
rasterImage() by default - this change was added for sp_0.9-64, and
this allows for quite large (up to available memory capacity)
SpatialGrids to be plotted efficiently with image(x).

However, in SDI mode a fresh R session seems only to support five uses
of rasterImage() that are drawn to a new device - the sixth and
subsequent draws make no visible difference - until the device is
manually resized. The problem cannot be reproduced in a single
windows() session.

To reproduce, in a fresh R session (Windows > 2.11.0 in SDI mode):

## create a dummy dataset
m<- matrix(c(0.2, 0.4, 0.6, 0.8), 2, 2)

## simple helper function to open the windows() device and plot the matrix
draw.f<- function(x) {
   plot(0, xlim = c(0, 1), ylim = c(0, 1))
   rasterImage(x, 0, 0, 1, 1, interpolate = FALSE)


## repeat the following 2 lines five times:


On the fifth attempt, only the background plot appears - but the
raster is visible on resize of the windows() device.

I sent this to Paul Murrell, and with Duncan Murdoch he isolated it to
the SDI mode of Windows.

I don't know that there is any prospect of a fix - presumably it is
rather deep down in the graphics code for Windows, but this note might
save some frustation. If anyone can offer more information to track
down where the problem is coming from that would be good.

Cheers, Mike.

R version 2.11.1 (2010-05-31)

[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] tools     stats     graphics  grDevices utils     datasets  methods
[8] base

Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner at gmail.com

More information about the R-sig-Geo mailing list