[GRASS-user] r.mapcalc --> 3 maps

Ciao grass users.

I have three maps A, B, C.

I would use r.mapcalc to combine them according to this logic:
Put the values of A and if A is null you put the values of B and if B is
null you put the values of C.

I have tried in various ways without success. .. now I'm trying with a
double IF...
r.mapcalc "output = if((isnull(a)),b,if(isnull(b)),c)" .....but in this
case I do not put the values of A

Help / advice?

Thanks
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalc-3-maps-tp5929440p5929440.html
Sent from the Grass - Users mailing list archive at Nabble.com.

I think you almost got there.

the IF condition would be this:

r.mapcalc "output = if((isnull(a)),b,if(isnull(b),c),a)"

so if A is null, use B, otherwise test if B is null. if it is, use C,
otherwise use A.

(note: this is from the top of my mind, I didn't tried it)

Hope this helps.

Carlos

On Sun, Jan 16, 2011 at 14:35, Gabriele N. <gis.gn@libero.it> wrote:

Ciao grass users.

I have three maps A, B, C.

I would use r.mapcalc to combine them according to this logic:
Put the values of A and if A is null you put the values of B and if B is
null you put the values of C.

I have tried in various ways without success. .. now I'm trying with a
double IF...
r.mapcalc "output = if((isnull(a)),b,if(isnull(b)),c)" .....but in this
case I do not put the values of A

Help / advice?

Thanks
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalc-3-maps-tp5929440p5929440.html
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Prof. Carlos Henrique Grohmann - Geologist D.Sc.
Institute of Geosciences - Univ. of São Paulo, Brazil
http://www.igc.usp.br/pessoais/guano
http://lattes.cnpq.br/5846052449613692
Linux User #89721
________________
Can’t stop the signal.

" r.patch - Creates a composite raster map layer by using known category values from one (or more) map layer(s) to fill in areas of “no data” in another map layer. "

" The GRASS program r.patch allows the user to build a new raster map the size and resolution of the current region by assigning known data values from input raster maps to the cells in this region. This is done by filling in “no data” cells, those that do not yet contain data, contain NULL data, or, optionally contain 0 data, with the data from the first input map. Once this is done the remaining holes are filled in by the next input map, and so on. This program is useful for making a composite raster map layer from two or more adjacent map layers, for filling in “holes” in a raster map layer’s data (e.g., in digital elevation data), or for updating an older map layer with more recent data. The current geographic region definition and mask settings are respected. "

http://grass.osgeo.org/grass64/manuals/html64_user/r.patch.html

2011/1/16 Gabriele N. <gis.gn@libero.it>

Ciao grass users.

I have three maps A, B, C.

I would use r.mapcalc to combine them according to this logic:
Put the values of A and if A is null you put the values of B and if B is
null you put the values of C.

I have tried in various ways without success. … now I’m trying with a
double IF…
r.mapcalc “output = if((isnull(a)),b,if(isnull(b)),c)” …but in this
case I do not put the values of A

Help / advice?

Thanks

View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalc-3-maps-tp5929440p5929440.html
Sent from the Grass - Users mailing list archive at Nabble.com.


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi Carlos and thanks.

A and B do not overlap, and I should take the values of A and B also
(always). Then.....in areas that are empty, I would then put the values of
C.

I tried with r.mapcalc "output = if((isnull(a)),b,if(isnull(b),a),c)"
but I lose the values of C
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalc-3-maps-tp5929440p5929564.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Sylvain and thanks.

I had not thought of "r.patch" and I think that works (but I have to
carefully examine the result)
I did so
r.patch input = a, b, c = output output_patch

Now I want to do it with r.mapcalc:)
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalc-3-maps-tp5929440p5929594.html
Sent from the Grass - Users mailing list archive at Nabble.com.

W dniu 16.01.2011 18:29, Gabriele N. pisze:

A and B do not overlap, and I should take the values of A and B also
(always). Then.....in areas that are empty, I would then put the values of
C.

I tried with r.mapcalc "output = if((isnull(a)),b,if(isnull(b),a),c)"
but I lose the values of C

This should work:

r.mapcalc 'd=if(isnull(a),if(isnull(b),c,b),a)'

If map a is null check if b is null too. If so, use c; if not - use b. Otherwise use a.

Or:

r.mapcalc 'd=if(isnull(a|||b),c,if(isnull(a),b,a))'

If both a and b are null, use c; if a is null use b, otherwise use a.

Maciek

--
Maciej Sieczka
http://www.sieczka.org

Gabriele N. wrote:

I have three maps A, B, C.

I would use r.mapcalc to combine them according to this logic:
Put the values of A and if A is null you put the values of B and if B is
null you put the values of C.

I have tried in various ways without success. .. now I'm trying with a
double IF...
r.mapcalc "output = if((isnull(a)),b,if(isnull(b)),c)" .....but in this
case I do not put the values of A

  r.mapcalc "output = if(!isnull(a),a,if(!isnull(b),b,c))"

--
Glynn Clements <glynn@gclements.plus.com>

Excellent Maciek and Glynn :slight_smile:

Although the logic is different (in the solution of Maciek I do a check
before the NULL value, while in the solution of Glynn I do a check before
non-NULL values), I believe that the result is the same.
One note: with the solution of Glynn (at least using the shell from QGIS) it
works with single quotes ' and not with double quote " .
gab@gab-laptop:~$ r.mapcalc "output_2 = if(!isnull(a),a,if(!isnull(b),b,c))"
bash: !isnull: event not found
gab@gab-laptop:~$ r.mapcalc 'output_2 = if(!isnull(a),a,if(!isnull(b),b,c))'
# OK

Thank you very much

Gabriele
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalc-3-maps-tp5929440p5932658.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Gabriele N. wrote:

Although the logic is different (in the solution of Maciek I do a check
before the NULL value, while in the solution of Glynn I do a check before
non-NULL values), I believe that the result is the same.
One note: with the solution of Glynn (at least using the shell from QGIS) it
works with single quotes ' and not with double quote " .
gab@gab-laptop:~$ r.mapcalc "output_2 = if(!isnull(a),a,if(!isnull(b),b,c))"
bash: !isnull: event not found

bash uses "!" for history expansion; single quotes disable all
expansions, while double quotes only prevent the string from being
split into words on whitespace. History expansion is only performed
for interactive shells, so it doesn't affect scripts or system().

--
Glynn Clements <glynn@gclements.plus.com>

Hy Glynn, thanks for the explanation.

Gabriele
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalc-3-maps-tp5929440p5952651.html
Sent from the Grass - Users mailing list archive at Nabble.com.