<html style="direction: ltr;">
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="latin-charset" bgcolor="#FFFFFF"
text="#000000">
<div class="moz-cite-prefix">On 01/02/2014 12:11 AM, Dave Roberts
wrote:<br>
</div>
<blockquote cite="mid:52C49279.2040002@ecology.msu.montana.edu"
type="cite">Hi Anna,
<br>
<br>
On 01/01/2014 01:50 PM, Anna Petrášová wrote:
<br>
<blockquote type="cite">Hi Dave,
<br>
<br>
<br>
<blockquote type="cite">On Wed, Jan 1, 2014 at 3:10 PM, Dave
Roberts
<br>
<<a class="moz-txt-link-abbreviated" href="mailto:dvrbts@ecology.msu.montana.edu">dvrbts@ecology.msu.montana.edu</a>
<a class="moz-txt-link-rfc2396E" href="mailto:dvrbts@ecology.msu.montana.edu"><mailto:dvrbts@ecology.msu.montana.edu></a>>
<br>
wrote:
<br>
<br>
Friends,
<br>
<br>
After some alternative approaches to a simple problem
of
<br>
compositing rasters (see previous posts, esp. compositing
rasters @9:32)
<br>
I developed a very crude function to update rasters
<br>
<br>
r.update target mask x y
<br>
<br>
updates raster target by substituting y everywhere that
raster mask
<br>
has x. A more GRASS-like syntax would be
<br>
<br>
r.update target=string mask=string current=integer
replace=integer
<br>
<br>
</blockquote>
<br>
I'm not sure if I don't miss anything but why don't you use
r.mapcalc
<br>
expression like this:
<br>
<br>
new = if(mask == x, y, target)
<br>
<br>
and then
<br>
<br>
g.rename new,target --overwrite
<br>
<br>
</blockquote>
well probably because I'm not too bright. Obviously your elegant
solution would allow multiple sequential updates just the way I
needed as long as I do the rename --overwrite very time. I knew
there had to e GRASS way to do this, I just hadn't figured it out
yet.
<br>
<br>
Thanks!
<br>
<br>
</blockquote>
<br>
The other quick and dirty workaround could be a combination of
r.reclass and r.series<br>
<br>
echo "1=2 \<br>
*=NULL" | r.reclass in=b out=b2<br>
echo "1=3 \<br>
*=NULL" | r.reclass in=c out=c3<br>
<br>
then:<br>
r.series in=a,b2,c3 out=target method=max<br>
<br>
Using method=max will avoid the problem of cells with values in more
than one original.<br>
<br>
Cheers,<br>
Micha<br>
<br>
<blockquote cite="mid:52C49279.2040002@ecology.msu.montana.edu"
type="cite">
<blockquote type="cite">Anna
<br>
<br>
<br>
but my bash skills are pretty limited and I elected (for the
time
<br>
being) not to parse the arguments that way. The current
function
<br>
relies on a short bash script and a FORTRAN executable. The
crude
<br>
part is exporting both the target an mask rasters as ascii
exports,
<br>
creating a new ascii file, and doing an r.in.ascii to bring
the
<br>
updated raster back in. It only works (at present) for
integer
<br>
rasters, but it's intended for thematic maps, so that seems
OK.
<br>
<br>
r.update.sh <a class="moz-txt-link-rfc2396E" href="http://r.update.sh"><http://r.update.sh></a> just below.
<br>
<br>
r.out.ascii inp=$1 out=$1.asc null=-1
<br>
r.out.ascii inp=$2 out=$2.asc null=-1
<br>
g.remove rast=$1
<br>
r_update $1.asc $2.asc $3 $4
<br>
r.in.ascii inp=tmp.file out=$1 nv=-1
<br>
rm $1.asc
<br>
rm $2.asc
<br>
rm tmp.file
<br>
<br>
You have to "alias r_update 'sh r_update.sh'" or name the
script
<br>
r.update and chmod +x r.update to make it run as shown.
<br>
<br>
The FORTRAN code for r_update is at
<br>
<br>
ecology.msu.montana.edu/GRASS/__r_update.f90
<br>
<a class="moz-txt-link-rfc2396E" href="http://ecology.msu.montana.edu/GRASS/r_update.f90"><http://ecology.msu.montana.edu/GRASS/r_update.f90></a>
<br>
<br>
The code compiles with gfortran. The executable must be in
your
<br>
path, or you can modify the bash script with a full path to
it.
<br>
<br>
It is my sincere hope that someone with GRASS chops
will write
<br>
a function for g.extension that uses the API and avoids all
this
<br>
ascii input and output, but this serves as a demo and useful
(if
<br>
clumsy) approach in the meantime.
<br>
<br>
Dave
<br>
--
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~__~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~__~~~~~~~~~~~~<br>
David W. Roberts office
<br>
406-994-4548 <tel:406-994-4548>
<br>
Professor and Head FAX
<br>
406-994-3190 <tel:406-994-3190>
<br>
Department of Ecology email
<br>
<a class="moz-txt-link-abbreviated" href="mailto:droberts@montana.edu">droberts@montana.edu</a> <a class="moz-txt-link-rfc2396E" href="mailto:droberts@montana.edu"><mailto:droberts@montana.edu></a>
<br>
Montana State University
<br>
Bozeman, MT 59717-3460
<br>
_________________________________________________
<br>
grass-user mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-rfc2396E" href="mailto:grass-user@lists.osgeo.org"><mailto:grass-user@lists.osgeo.org></a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/__mailman/listinfo/grass-user">http://lists.osgeo.org/__mailman/listinfo/grass-user</a>
<br>
<a class="moz-txt-link-rfc2396E" href="http://lists.osgeo.org/mailman/listinfo/grass-user"><http://lists.osgeo.org/mailman/listinfo/grass-user></a>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>