In summary, I have for example 3 maps A, B, C.
I need to combine the values of the overlapping cells. For example if I have
a cell in the map "A" with value 11, in the corresponding cell of the map
"B" I have 2222 and the corresponding cell of the map "C" is 3333.
In output I would like to have a map that has a value in that cell
1122223333.
I tried with r.mapcalc, but without Successfully.
In summary, I have for example 3 maps A, B, C.
I need to combine the values of the overlapping cells. For example if I have
a cell in the map "A" with value 11, in the corresponding cell of the map
"B" I have 2222 and the corresponding cell of the map "C" is 3333.
In output I would like to have a map that has a value in that cell
1122223333.
I tried with r.mapcalc, but without Successfully.
Help?
Thanks
Gabriele
The quick way to do this classically is using reclassification
techniques. Are the number of digits the same for all of A, B and C?
If so
(A * 100000000)+ (B*10000)+C would get you that answer
Usually with Raster processing you have to think of ways to solve using
only math, hence concatenation not working. Now if you converted your
grids to polygons that would be totally different.
Excellent Alex:). The maps are as follows:
A -> value 0, 1, 2, ... 19
B -> value 0, 1001, 1002, 1003 .... 3351
C -> value from 0, 1, 2, 3, 4 ...... 15
So, I did as you suggested:
r.mapcalc "output" = "(( "A" *1000000)+( "B" *100)+ "C" )"
right?
And .... if I had decimal numbers or strings instead of numbers?
Excellent Alex:). The maps are as follows:
A -> value 0, 1, 2, ... 19
B -> value 0, 1001, 1002, 1003 .... 3351
C -> value from 0, 1, 2, 3, 4 ...... 15
So, I did as you suggested:
r.mapcalc "output" = "(( "A" *1000000)+( "B" *100)+ "C" )"
right?
And .... if I had decimal numbers or strings instead of numbers?
Thanks
Gabriele
Strings in a raster map?
With decimal numbers it works the same way. Or you multiply the map with number of digits and handle it as an integer map (maybe that does not work because of limited bit information per pixel).
Hi Achim.
Returning to the problem of the three maps in some cases remain the problem
(for example for the map "C"), because some numbers are 2 digits and another
with 1 digit.
For example, with values A = 12 B = 3323 C = 1 instead of 1233231 I have
12332301
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Values-from-multiple-raster-to-link-together-tp5741032p5741869.html
Sent from the Grass - Users mailing list archive at Nabble.com.
Hi Achim.
Returning to the problem of the three maps in some cases remain the problem
(for example for the map "C"), because some numbers are 2 digits and another
with 1 digit.
For example, with values A = 12 B = 3323 C = 1 instead of 1233231 I have
12332301
Sorry, but I dont understand the problem. How do you know the origin number later when eg C has sometimes length 1 and sometimes more?
Sorry, I have not explained well.
The problem was related to the value of C map. That is, I take the example
above. If the value of C map is equal to 1, I get a result -> A =12 B=3323
C=1 =12332301 (8 digit number) and instead could be useful 1233231 (number
7-digit).
However I checked and I need a value to 8 digits ..... so ok:)
On Tue, Nov 16, 2010 at 2:51 PM, Gabriele N. <gis.gn@libero.it> wrote:
Sorry, I have not explained well.
The problem was related to the value of C map. That is, I take the example
above. If the value of C map is equal to 1, I get a result -> A =12 B=3323
C=1 =12332301 (8 digit number) and instead could be useful 1233231 (number
7-digit).
However I checked and I need a value to 8 digits ..... so ok:)
Hy Daniel.
I do not think that r.cross can solve the problem.
With r.cross I could get a concatenation of label:
For example, with values A = 12 B = 3323 C = 1 the result with the label
"category 12, category 3323, category 1"
However, if you know a chance I can prove otherwise.
As a result, the value of cell in the raster output should be 12332301
Ok, I misunderstood your problem. You want the concatenated values,
not just the map of the different crossings. Maybe use r.cross and
then some grep magic in the raster category file
Daniel
On Tue, Nov 23, 2010 at 10:02 AM, Gabriele N. <gis.gn@libero.it> wrote:
Hy Daniel.
I do not think that r.cross can solve the problem.
With r.cross I could get a concatenation of label:
For example, with values A = 12 B = 3323 C = 1 the result with the label
"category 12, category 3323, category 1"
However, if you know a chance I can prove otherwise.
As a result, the value of cell in the raster output should be 12332301
I have a new problem, this time I would like to concatenate two maps A and B.
A is with 8 digits, B is with 4 digits. So I do as usual:
r.mapcalc "output" = "((" A "* 10000) (" B "))"
But I get strange values with negative values. I did several tests but
without resolve. Perhaps r.mapcalc may have problems with numbers greater
than 10 digits
It's not r.mapcalc fault. I imagine it's probably a limitation due to
the number of bits in your image. For instance, 8 bit images can have
up to 256 values. 16 bit images can have 65,535. So, if you have too
many values, you will have problems. Not sure how to avoid this in
your case but, maybe you will need to work with categories after all.
Are you planing on doing any math operations in the concatenated
values or is it more for displaying pourposes?
On Tue, Nov 23, 2010 at 4:34 PM, Gabriele N. <gis.gn@libero.it> wrote:
I have a new problem, this time I would like to concatenate two maps A and B.
A is with 8 digits, B is with 4 digits. So I do as usual:
r.mapcalc "output" = "((" A "* 10000) (" B "))"
But I get strange values with negative values. I did several tests but
without resolve. Perhaps r.mapcalc may have problems with numbers greater
than 10 digits
I have a new problem, this time I would like to concatenate two maps A and B.
A is with 8 digits, B is with 4 digits. So I do as usual:
r.mapcalc "output" = "((" A "* 10000) (" B "))"
But I get strange values with negative values. I did several tests but
without resolve. Perhaps r.mapcalc may have problems with numbers greater
than 10 digits
CELL maps contain signed, 32-bit values using sign-bit representation,
so the range is -2147483647 to 2147483647 inclusive (i.e. -(2^31-1) to
2^31-1). So you aren't going to be able to store 12-digit numbers in a
CELL map.
DCELL maps use the C "double" type, which on most systems is IEEE-754
double precision, which has a 53-bit mantissa, plus a separate sign
bit. That can exactly represent any integer between -9007199254740992
and 9007199254740992 inclusive (i.e. almost 16 decimal digits).
However, depending upon what you want to do with the result, this may
not be an option, as not all modules can work with floating-point
data.
It's not r.mapcalc fault. I imagine it's probably a limitation due to
the number of bits in your image. For instance, 8 bit images can have
up to 256 values. 16 bit images can have 65,535. So, if you have too
many values, you will have problems. Not sure how to avoid this in
your case but, maybe you will need to work with categories after all.
Are you planing on doing any math operations in the concatenated
values or is it more for displaying pourposes?
Hi Daniel...
Maybe it would be useful only concatenation but I would also have the
possibility to apply tools such as r.statistics and other similar that work
on the value of cells.
The multiply will cause A to be converted to double to match the other
argument (floating-point constants are double unless an explicit "f"
suffix is given), the multiply will yield a double result, and the
addition will convert B to double to match this.
The multiply will cause A to be converted to double to match the other
argument (floating-point constants are double unless an explicit "f"
suffix is given), the multiply will yield a double result, and the
addition will convert B to double to match this.
perfect, I tried it and it actually works:) This speeds up operations.
Now I have to combine new maps and then to reclassify the maps, I will use
r.recode ... we'll see what happens:)