Two-layered question:

When I use the raster package to plot a raster dataset, the plot comes out
the way I expect.  However, when using the spatstat package to plot it, the
image is inverted. Is that because I've made a mistake in translating the
raster object into an pixel image object, or is there something I need to
do in the call to the plot function? Example below:

library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
# this is what I expect it to look like
plot(logo)

library(spatstat)
# convert raster object to as.im()
R.im<-as.im(X=as.matrix(logo))
# inverts the plot and values.
plot(R.im, axes=T)

Second question. I would like to randomly sample the raster/pixel image
(ie. the R logo in this example).  For example, I would like to randomly
sample the image from a normal distribution, extracting the xy coordinates
of my samples.  How would I randomly sample 100 points from the R logo from
this example distribution rnorm(n=100, mean=100, sd=5)?

Many thanks,

Tim

	[[alternative HTML version deleted]]

