[R] plotting rasters - no plot, no error

Michael Sumner mdsumner at gmail.com
Wed Apr 15 01:16:45 CEST 2015


On Wed, 15 Apr 2015 at 02:49 Monica Pisica <pisicandru at hotmail.com> wrote:

> Hi Mike,
>
>
> Very interesting. The plot itself on the computer that does not plot -
> still does not plot - no surprise there. But the command with useRaster =
> FALSE actually plots the raster. So that means it is something wrong with
> the raster package? Did i forget to install some dependency, although i
> though i ask for all to be installed?
>
>
>
Is this through Windows Remote Desktop? There's a note in ?rasterImage:

" Problems with the rendering of raster images have been
     reported by users of ‘windows()’ devices under Remote Desktop, at
     least under its default settings.
"

and see here:

https://stat.ethz.ch/pipermail/r-help//2013-July/357287.html

Note that raster::plot has arguments for the underlying image functions
 graphics::image and graphics::rasterImage - these are "interpolate" and
"useRaster".  The terminology is confusing, partly because rasterImage()
and its underlying code was put in base R at around the same time as the
extension package "raster" appeared. (rasterImage was originally called
"raster" so it's less confusing than it might have been)

The details get hidden because of the high-level plot() and image()
functions (and raster's additional methods for those), but essentially for
tracking down the ultimate cause you should see if you can reproduce with
the following four lines (without raster loaded):

data(volcano)
vn <- (volcano - min(volcano)) / diff(range(volcano))

## for each 1-4, close any open graphics windows first
## just to be sure (use dev.off() for convenience)

# 1.  image.default
image(vn)

# 2. rasterImage via image.default
image(vn, useRaster = TRUE)

# 3. rasterImage with interpolation
plot(0, xlim = c(0, 1),ylim = c(0,1), type = "n")
rasterImage(vn, 0, 0, 1, 1)

# 4. rasterImage without interpolation
plot(0, xlim = c(0, 1),ylim = c(0,1), type = "n")
rasterImage(vn, 0, 0, 1, 1,  interpolate = FALSE)

If you can reproduce the problem with these four cases, you have a clearer
basis to work from. These are the components from with raster's plot
methods are built, and I don't think raster is to blame here.

There might be settings for colour you can control with Remote Desktop.

Cheers, Mike.

I still don't know how to solve the problem, but thanks so much for an
> alternative way to actually plot my rasters.
>
>
> Monica
> ________________________________
> > From: mdsumner at gmail.com
> > Date: Tue, 14 Apr 2015 15:18:01 +0000
> > Subject: Re: [R] plotting rasters - no plot, no error
> > To: pisicandru at hotmail.com; r-help at r-project.org
> >
>
> > On Wed, 15 Apr 2015 at 01:16 Michael Sumner
> > <mdsumner at gmail.com<mailto:mdsumner at gmail.com>> wrote:
> > On Wed, 15 Apr 2015 at 00:50 Monica Pisica
> > <pisicandru at hotmail.com<mailto:pisicandru at hotmail.com>> wrote:
> >
> > Hi,
>
> > I have the current version of R installed on 2 different Windows
> > computers. On one i can plot using the plot function a raster in geotif
> > format, on the other it plots only the axis, an empty color bar and no
> > raster what so ever without generating any errors or warnings. So i
> > suspect something is not installed properly, but i don't know what. Do
> > you have any clues? I would really appreciate any insights. I need some
> > instructions i can pass on to an IT person since i don't have rights on
> > the computer that does not plot the raster.
>
> > Hello, can you try these on both systems and see if there's a difference?
> >
> > library(raster)
> > plot(raster(volcano))
> >
> > plot(raster(volcano), useRaster = TRUE)
>
> > Ugh, sorry I meant to try this:
> >
> > plot(raster(volcano), useRaster = FALSE)
> >
> > otherwise both calls are equivalent.
> >
> > Cheers, Mike.
> >
>
> > the useRaster argument refers to use of graphics::rasterImage rather
> > than image.defaul under (package) raster's hood.
> >
> > Cheers, Mike.
>
> > On both computers i can plot lines, points, polygons, as graphic
> > objects or shapefiles.
>
> > Thanks so much, Monica
>
> > The first PC that plots the raster:
> >
> > Sys.info()
> >
> > sysname release
> > version
> >
> > "Windows" "7 x64" "build 7601,
> > Service Pack 1"
> >
> > nodename machine
> > login
> >
> > "NODENAME" "x86-64"
> > "LOGIN"
> >
> > user effective_user
> >
> > "MONICA" "MONICA"
>
> > R.Version()
> >
> > $platform
> >
> > [1] "x86_64-w64-mingw32"
>
> > $arch
> >
> > [1] "x86_64"
>
> > $os
> >
> > [1] "mingw32"
>
> > $system
> >
> > [1] "x86_64, mingw32"
>
> > $status
> >
> > [1] ""
>
> > $major
> >
> > [1] "3"
>
> > $minor
> >
> > [1] "1.3"
>
> > $year
> >
> > [1] "2015"
>
> > $month
> >
> > [1] "03"
>
> > $day
> >
> > [1] "09"
>
> > $`svn rev`
> >
> > [1] "67962"
>
> > $language
> >
> > [1] "R"
>
> >
> > $version.string
> >
> > [1] "R version 3.1.3 (2015-03-09)"
>
> > $nickname
> >
> > [1] "Smooth Sidewalk"
>
> > Libraries i loaded: maptools, raster, rgdal, sp, CircStats, rgeos,
> stringr
>
> > The computer that does not plot the raster:
> >
> > Sys.info()
> >
> > sysname release
> > version nodename
> >
> > "Windows" "Server 2008 x64" "build 7601,
> > Service Pack 1" "NODENAME"
> >
> > machine login
> > user effective_user
> >
> > "x86-64" "MONICA"
> > "MONICA" "MONICA"
>
> > R.Version()
> >
> > $platform
> >
> > [1] "x86_64-w64-mingw32"
>
> > $arch
> >
> > [1] "x86_64"
>
> > $os
> >
> > [1] "mingw32"
>
> > $system
> >
> > [1] "x86_64, mingw32"
> >
>
> > $status
> >
> > [1] ""
> >
>
> > $major
> >
> > [1] "3"
>
> > $minor
> >
> > [1] "1.3"
> >
>
> > $year
> >
> > [1] "2015"
>
> > $month
> >
> > [1] "03"
> >
>
> > $day
> >
> > [1] "09"
>
> > $`svn rev`
> >
> > [1] "67962"
> >
>
> > $language
> >
> > [1] "R"
>
> > $version.string
> >
> > [1] "R version 3.1.3 (2015-03-09)"
>
> > $nickname
> >
> > [1] "Smooth Sidewalk"
>
> > Libraries i loaded: maptools, raster, rgdal, sp, CircStats, rgeos,
> stringr
>
> > again thanks so much,
> >
> > Monica
>
> > ______________________________________________
> > R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To
> > UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list