[GRASS-user] Re: r.surf.nnbathy interpolation to whole region

Maciej Sieczka tutey at o2.pl
Thu Sep 6 12:25:27 EDT 2007


Luigi Ponti wrote:
> Maciej Sieczka wrote:
>> Luigi Ponti wrote:
>>> Maciej Sieczka wrote:
>>>> Luigi Ponti wrote:

>>>> It sounds feasible to add this functionality to
>>>> r.surf.nnbathy, but I don't know if the approach is correct
>>>> from the GIS point of view (i.e., mixing two interpolation
>>>> methods) or even more useful/better than just using IDW for
>>>> the whole region.

>> It is possible to add such a functionality to r.surf.nnbathy, but 
>> I'd rather leave it to the user to enhance his input raster the 
>> way he prefers to, if necessary. Different interpolation methods 
>> or additional data sources can be used to add the 4 corner points 
>> in question.

> Any pointer to getting the four corners? Maybe they are already 
> there, i.e. the code that sets the working region for nnbathy?
> 
> # set the working region for nnbathy (it's cell-center oriented) 
> nn_n=`echo $n | awk -v res="$nsres" '{printf "%.8f",$1-res/2.0}'` 
> nn_s=`echo $s | awk -v res="$nsres" '{printf "%.8f",$1+res/2.0}'` 
> nn_w=`echo $w | awk -v res="$ewres" '{printf "%.8f",$1+res/2.0}'` 
> nn_e=`echo $e | awk -v res="$ewres" '{printf "%.8f",$1-res/2.0}'`
> 
> Though I don't entirely understand what it does, it seems to be 
> getting the coordinates of the center of cells located at the 4 
> corners of the region.

It calculates the working region for nnbathy, so that it reflected the
current GRASS region. Since nnbathy is cell-center oriented each
N,S,E,W extent has to be shifted half a current GRASS region resolution
to avoid it's output missalignment with current GRASS region. This is
achieved with awk maths as above.

You can calculate the corners of your current GRASS region from the
output of g.region -g.

Maciek




More information about the grass-user mailing list