[GRASS-user] How to merge rasters using feathering/blending ?

Jamie Adams jaadfoo at gmail.com
Mon Feb 28 14:55:35 EST 2011


I wrote a script to do something like this at one point, though I can't find
it now.  It was intended for terrain, but could be used per band on imagery.
 It used r.buffer to create a distance gradient and then r.recode to convert
this gradient to a percentage.  I then used r.mapcalc to merge the 2 rasters
based on the percentage.

The script automated the buffer distances and the creation of the recode.txt
file, but went something like this:

## make a null raster
r.mapcalc "temp_null = if(isnull(source),1,null)"

## create a distance gradient from the null raster.  The output will have
int values 1-7 where 1 equals the input null raster
r.buffer in=temp_null out=temp_buf distances=10,20,30,40,50,60 units=meters

## fill nulls in the distance gradient with 0 for recoding
r.mapcalc "temp_buf_fill=if(isnull(temp_buf),0,temp_buf)"

## recode to a percentage
r.recode in=temp_buf_fill out=temp_recode rules=recode.txt

where recode.txt would have the range from temp_buf_fill expressed as
percentages:
1:1:100:100
2:2:86:86
3:3:71:71
4:4:57:57
5:5:43:43
6:6:29:29
7:7:14:14
0:0:0:0

## merge the output
r.mapcalc
"merged=if(isnull(source),patch,(patch*(temp_recode/100.0))+(source*(1.0-(temp_recode/100.0))))"

Sorry if that doesn't work, but hopefully you get the idea.

- Jamie

On Thu, Feb 24, 2011 at 10:53 AM, kaipi <mapcollect at gmx.net> wrote:

>
> I need to patch rasters containing NULL areas with alternative rasters. I
> can
> do this with r.patch but due to different quality/resolution of the rasters
> this produces prominent seamlines. Is there a way to feather/blend between
> merged rasters using Grass GIS?
>
> Thanks,
>
> Kaipi
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/How-to-merge-rasters-using-feathering-blending-tp6061489p6061489.html
> Sent from the Grass - Users mailing list archive at Nabble.com.
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20110228/72bb2a85/attachment-0001.html


More information about the grass-user mailing list