[GRASS-user] Slope categories from DEM ?

Hello,

I am new to GRASS and I need to compute, from a DEM, a map showing the areas with a slope lower than 30%. So basically I would like 2 slope categories, <30% and >30%, but I am quite lost in the way I should do it. Could you please sketch me the steps to achieve it?

Thanks a lot for your help!
Emma

Hi,

2010/11/6 Emma <emma@seleeg.org>:

I am new to GRASS and I need to compute, from a DEM, a map showing the areas
with a slope lower than 30%. So basically I would like 2 slope categories,
<30% and >30%, but I am quite lost in the way I should do it. Could you
please sketch me the steps to achieve it?

generate slope map with

r.slope.aspect elevation=dem_map slope=slope_map format=percent

and then reclass slope map by r.mapcalc

r.mapcalc 'slope_30 = if(slope_map > 30, 1, 0)'

r.mapcalc generates raster map with two values - 1 for areas where
slope is greater then 30% and 0 for areas where slope is lower or
equal then 30%.

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

On Sat, 6 Nov 2010, Martin Landa wrote:

r.mapcalc 'slope_30 = if(slope_map > 30, 1, 0)'

r.mapcalc generates raster map with two values - 1 for areas where slope
is greater then 30% and 0 for areas where slope is lower or equal then
30%.

Martin,

   Is the reverse 'slope_30 = if(slope_map < 30, 1, 0)' mean that areas = 1
are < than 30% and areas with 0 are >= 30%?

   My question is the value of areas where slope = 30% are placed with the
different mapcalc expressions.

Thanks,

Rich

Rich,

The if syntax in r.mapcalc is as follows:

if(test condition, response if true, response if false)

So, by reversing the test in the if statement will give you values of
1 for low slope areas.

Check out the r.mapcalc man page for the complete if syntax

Daniel

On Sat, Nov 6, 2010 at 4:06 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Sat, 6 Nov 2010, Martin Landa wrote:

r.mapcalc 'slope_30 = if(slope_map > 30, 1, 0)'

r.mapcalc generates raster map with two values - 1 for areas where slope
is greater then 30% and 0 for areas where slope is lower or equal then
30%.

Martin,

Is the reverse 'slope_30 = if(slope_map < 30, 1, 0)' mean that areas = 1
are < than 30% and areas with 0 are >= 30%?

My question is the value of areas where slope = 30% are placed with the
different mapcalc expressions.

Thanks,

Rich
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

On Sat, 6 Nov 2010, Daniel Victoria wrote:

So, by reversing the test in the if statement will give you values of 1
for low slope areas.

   In the question asked to start this thread, there's apparently no interest
in values == 30%. By default, those are included in the false category. And
if one wants them included in the true category the test condition needs to
be <= rather than just <.

Rich

Dear all,

Thanks a lot for your answers. I tried the following:
----------------
1.
r.slope.aspect elevation=new_dem slope=new_slope format=degrees

2.
r.reclass input=new_slope output=new_slope_30 rules=grassrule.txt

where grassrule.txt contained:
1 thru 30 = 1
31 thru 90 = 2
----------------
This works pretty well and the result corresponds to what I wanted. Great !!

Now I also tried to use r.mapcalc instead of r.reclass as follows:
r.mapcalc 'new_slope_30_bis = if(new_slope > 30, 1, 0)'

However for some reason the resulting map new_slope_30_bis has:
Rows: 20
Columns: 20
Total Cells: 400

while the original new_slope, as well as new_slope_30 have both Total Cells: 47212692. So you can imagine the result is not very nice...

Why is this happening ? (and am I allowed to attach screenshots to my emails in this mailing list??)

Sincerely yours,
Emma

On 6-Nov-10, at 10:08 PM, Rich Shepard wrote:

On Sat, 6 Nov 2010, Daniel Victoria wrote:

So, by reversing the test in the if statement will give you values of 1
for low slope areas.

In the question asked to start this thread, there's apparently no interest
in values == 30%. By default, those are included in the false category. And
if one wants them included in the true category the test condition needs to
be <= rather than just <.

Rich

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

2010/11/6 Emma <emma@seleeg.org>:

Now I also tried to use r.mapcalc instead of r.reclass as follows:
r.mapcalc 'new_slope_30_bis = if(new_slope > 30, 1, 0)'

However for some reason the resulting map new_slope_30_bis has:
Rows: 20
Columns: 20
Total Cells: 400

while the original new_slope, as well as new_slope_30 have both Total Cells:
47212692. So you can imagine the result is not very nice...

raster modules operate on the computational region, try to set up the
region based on slope map before you run r.mapcalc

g.region rast=new_slope
r.mapcalc ...

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

On 6-Nov-10, at 10:41 PM, Martin Landa wrote:

2010/11/6 Emma <emma@seleeg.org>:

Now I also tried to use r.mapcalc instead of r.reclass as follows:
r.mapcalc 'new_slope_30_bis = if(new_slope > 30, 1, 0)'

However for some reason the resulting map new_slope_30_bis has:
Rows: 20
Columns: 20
Total Cells: 400

while the original new_slope, as well as new_slope_30 have both Total Cells:
47212692. So you can imagine the result is not very nice...

raster modules operate on the computational region, try to set up the
region based on slope map before you run r.mapcalc

g.region rast=new_slope
r.mapcalc ...

Right, this solved the problem! Thanks