[R-sig-Geo] doubts with density ppp function
Rolf Turner
r.turner at auckland.ac.nz
Wed Oct 10 01:00:43 CEST 2012
On 09/10/12 23:16, Julia Chacon Labella wrote:
> Just a short and simple question,
>
> How can I extract the values of an image created with "density.ppp"
> function?
See ?"[.im".
Let your image be called "A".
If you have coordinates x and y at which you wish to extract the
image values you can use:
A[i=data.frame(x=x,y=y)]
If you have pairs of indices (of pixels) at which you want to extract
the image values you can form an n x 2 matrix (say "M") each row
of which is an index pair and use
A[i=M]
>
> And...there is any way to rotate this images? I tried with rotate() but I
> guess this is only for the ppp object, not for an image.
>
You can use the affine.im() method for affine(). Or write a wrapper,
rotate.im() for affine.im(), something like:
rotate.im <- function(X,theta=pi/2) {
co <- cos(theta)
si <- sin(theta)
m <- matrix(c(co,si,,-si,co),2,2)
affine(X,mat=m)
}
HTH
cheers,
Rolf Turner
More information about the R-sig-Geo
mailing list