[GRASS-user] subsampling to a coarser resolution

Glynn Clements glynn at gclements.plus.com
Wed Sep 2 17:15:48 EDT 2009


jamesmcc wrote:

> I didnt realize that bilinear was what I was doing, though I'm familiar with
> it. This should work, though I immediately become concerned by the first
> line of the documentation
> 
> r.resamp.interp - Resamples raster map layers to a finer grid using
> interpolation. 
> 
> since I'm not going to a finer resolution. I noticed that you are the
> author, so I thought I should say something! :)

It isn't limited to upsampling, although that's the main use.

> One point of clarification in the equations you wrote, are the xy coords in
> the input raster and in the current region are normalized by the resolution
> of the input raster? 

Yes; those equations assume that x and y are in input cells, e.g. 
0.5,0.5 is the centre of the top-left cell.

> Lastly, r.what looks nice but I have to kinda scratch my head. While I
> appreciate being able to query the raster value at a specific geographic
> location, I use GIS so that IT will keep track of the positions. I want to
> get the values based on row,column of the raster not north,east... clearly,
> if i could figure out how to get north,east from row,column I'd just pipe
> this to r.what, but I havent figured that out either. 

You can obtain the coordinates using the output from r.info, e.g.:

	inmap=...
	row=...
	col=...
	eval `r.info -gs $inmap` # sets north,south,east,west,nsres,ewres
	n=`echo "$north - ($row + 0.5) * $nsres" | bc`
	e=`echo "$west + ($col + 0.5) * $ewres" | bc`
	r.what $inmap east_north=$e,$n

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


More information about the grass-user mailing list