Hi Roman-
Thanks for the tip on transposing the data. This is part of the solution,
but the plot is still rotated -90 degrees, but I think I can figure out how
to solve that with a little more playing.  I'm not sure I understand the
logic of the spatstat format, but at least I should be able to deal with it.

Regarding the random sampling, after thinking about it a little more, I
hope to convey my thoughts a little better this way.  I'll stick with the R
logo example, plotted from the raster package for this:

library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
plot(logo)

The raster values range from 0 to 255.  Say I want to take 100 random
samples of the raster values normally distributed around a mean of 100,
with an sd of 5.  When I take those 100 random samples, I want to know the
x,y coordinates associated with those samples.

rnorm(n=100, mean=100, sd=5)

If histograms are plotted of the above distribution hist(rnorm(n=100,
mean=100, sd=5)),

maybe this means:

sampling around the mid-points of the histograms: hist(rnorm(n=100,
mean=100, sd=5))$mids
with sampling probabilities defined by the histogram densities:
hist(rnorm(n=100, mean=100, sd=5))$density

Many thanks,

Tim


On Thu, Aug 22, 2013 at 3:53 AM, Roman Luštrik <roman.lustrik@gmail.com>wrote:

> Hello Tim,
>
> it's expected behavior to see an inverted image when you use `im` for
> plotting. You can use `t` to rotate the image.
>
> What do you mean by sampling an image using normal distribution? What
> values should be normally distributed? Can you expand this question a bit?
>
> Cheers,
> Roman
>
>
> On Wed, Aug 21, 2013 at 9:57 PM, Tim Sippel <tsippel@gmail.com> wrote:
>
>> 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]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
>
> --
> In God we trust, all others bring data.
>

	[[alternative HTML version deleted]]

