[R-sig-Geo] problem with raster calculation

Babak Naimi naimi at itc.nl
Wed Nov 2 16:50:27 CET 2011


Dear Aidin,

I tested your example with the latest version of raster package on R 2.12.2 (windows), got the same problem! But on R 2.13.0 (linux), and R 2.13.2 and 2.14 (windows), it works fine!

Best regards,
Babak


-----Original Message-----
Date: Tue, 1 Nov 2011 16:36:52 +0100
From: Aidin Niamir <niamir at gmail.com>
To: r-sig-geo at r-project.org
Subject: [R-sig-Geo] problem with raster calculation
Message-ID:
	<CAC+VNxqWyBcZGLGDr5K6MHV9xymE4HaO9SPPvDypfN35w8tMEA at mail.gmail.com>
Content-Type: text/plain

Dear all

I am experiencing a strange problem when calculating in the raster package.
Let me explain it with a simple expample;

> a <- c(1,1,1,0,0,0,2,2,2)
> a <- matrix(a,3,3,byrow=T)
> a <- raster(a)
> a []
[1] 1 1 1 0 0 0 2 2 2
> b <- 10 - a
> b []
[1]  -9  -9  -9 -10 -10 -10  -8  -8  -8

As you can see, the obtained values are not correct. I cannot see why this
should be.
Can anybody help?

Aidin

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list