[R-sig-Geo] as.raster() does not work for RImageJ objects

Agustin Lobo alobolistas at gmail.com
Fri Jan 17 09:09:25 CET 2014


Actually, in OSX, there is no error message at using as.raster(), but
it does not work either:

r <- as.raster(image)
class(r)

[1] "raster"
> str(r)
'raster' chr [1:76, 1:100] "#ffffff" "#ffffff" "#ffffff" "#ffffff"
"#ffffff" "#ffffff" "#ffffff" ...

which is not the structure a raster object should have.

Then:

r <- as.raster.jobjRef(image)
Error: could not find function "as.raster.jobjRef"

while ?as.raster.jobjRef shows the help page
the function as.raster.jobjRef" is not in the workspace (and this is
also the case in linux):
> search()
 [1] ".GlobalEnv"        "package:RImageJ"   "package:rJava"
"package:raster"    "package:sp"
 [6] "tools:rstudio"     "package:stats"     "package:graphics"
"package:grDevices" "package:utils"
[11] "package:datasets"  "package:methods"   "Autoloads"
"package:base"
> ls(2)
[1] "IJ"              "IJWindowManager" "ImageJ"


R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
  [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
  [1] RImageJ_0.2-146 rJava_0.9-6     raster_2.1-66   sp_1.0-13

loaded via a namespace (and not attached):
  [1] grid_3.0.2      lattice_0.20-23 tools_3.0.2


Agus

On Thu, Jan 16, 2014 at 4:09 PM, Agustin Lobo <alobolistas at gmail.com> wrote:
> Hi!
>
> While the following works fine:
> install.packages("/home/alobo/Downloads/RImageJ_0.2-146.tar.gz", repos
> = NULL, type="source")
> require(RImageJ)
> require(raster)
> logo <- system.file( "images", "R.jpg", package = "RImageJ" )
> image = IJ$openImage( logo )
> class(image)
> plot(c(100, 250), c(300, 450), type = "n", xlab="", ylab="")
> rasterImage(image, 100, 300, 150, 350, interpolate=FALSE)
>
> (note that the example in
> http://romainfrancois.blog.free.fr/index.php?category/R-package/RImageJ
> is currently wrong, it must be rasterImage() and not raster()
>
> But as.raster() (the most important for me) does not work:
>
>> class(image)
> [1] "jobjRef"
> attr(,"package")
> [1] "rJava"
>> r <- as.raster(image)
> Error in as.raster.jobjRef(image) : attempt to apply non-function
>
> see ?as.raster.jobjRef
>
> Any fix?
>
> Thanks
> Agus



More information about the R-sig-Geo mailing list