maning wrote:

> I'm testing r.hazard.flood and noticed that it computes the flood and
> mti layers on the full region of the elevation raster instead of the
> pre-defined region settings.
> 
> The relvant code I found from the r.hazard.flood is this:
>    # Detect cellsize of the DEM
>     info_region = grass.read_command('g.region', flags = 'p', 
> rast =
> '%s' % (r_elevation))
>     dict_region = grass.parse_key_val(info_region, ':')
>     resolution = (float(dict_region['nsres']) + 
> float(dict_region['ewres']))/2
>     grass.message("Cellsize : %s " % resolution)
> 
> Would it be possible to either respect the current region settings or
> add a flag to choose between the dem region settings or current region
> settings?


if it needs to detect the original raster cell resolution (usually that's only 
needed to avoid aliasing artifacts in certain situations) it should use r.info 
to get the answer. I'm guessing due to the averaging of the ew and ns 
resolutions avoiding aliasing isn't the case.

if a module wants to change the region (and almost none should ever do that 
except for g.region by itself) it should set up a temporary WIND_OVERRIDE 
first, in the case of python scripting there is an easy grass python function 
to make that and clean it up at the end. (otherwise parallel jobs get their 
regions messed up mid-run, and region changes without you expecting it will)

I suspect grass.raster's raster_info() is the better way for r.hazard.flood to 
do what it's trying to do now. But also just querying the current g.region info 
without changing anything is probably even better, as that is what the other 
raster commands will expect to use. If the user should align perfectly with the 
input map first, it should be noted in the help page for them to do it manually 
before running the module.


regards,
Hamish

_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to