[GRASS-user] How to get the area of a polygon in a layer

Nikos Alexandris nik at nikosalexandris.net
Mon Oct 15 21:10:49 PDT 2018


Kalindu Perera:

>Commands are as follows
>
>*r.ros,*
>r.ros --overwrite model=fuel_model at demomapset
>moisture_1h=1hour_moisture at demomapset moisture_live=live_moisture at demomapset
>velocity=wind_speed at demomapset direction=wind_direction at demomapset
>slope=slope at demomapset aspect=aspect at demomapset
>elevation=elevation at demomapset base_ros=my_ros.base max_ros=my_ros.max
>direction_ros=my_ros.maxdir spotting_distance=my_ros.spotdist
>
>*r.spread,*
>r.spread --overwrite base_ros=my_ros.base at demomapset
>max_ros=my_ros.max at demomapset direction_ros=my_ros.maxdir at demomapset
>start=fire_origin at demomapset wind_speed=wind_speed at demomapset
>output=spread_time_observed
>
>*After entering; r.category spread_time_observed,*
>[image: 1.png]
>
>*After entering; r.report spread_time_observed units=c,p,*
>[image: Screenshot from 2018-10-15 21-40-46.png]

Dear Kalindu,

thank you for the above.

If all is right, you might just need to properly prepare the input data
and/or the output of `r.ros`, for example, to label raster categories
appropriately.  Then, modules like `r.report` will show also the label
for each raster category.

When drawing the `spread_time_observed` map, can you identify visually the
raster category of your interest?  If yes, pick up the the "Query
raster/vector map(s)" tool (4th button in wxGUI's Map Display window),
and select any pixel of the category of your interest.  This will tell
the value (of the pixel you selected) and a label (if any is given).

Knowing this value, you can extract all pixels of this value using
`r.mapcalc`. For example, say the raster category (or value) of
interest, is 3. Then, something like
```
r.mapcalc "category_3 = if(spread_time_observed == 3, 3, null())"
```
will create a map with all pixels of value 3.

I guess using this "category_3" map as an input to `r.surf.area` would
give the area estimation you require. Please, take care to read the
NOTES in `r.surf`area`'s manual about "edge effects" though.


Else, I think the easiest/fastest for me would to be to have access to sample
data (even via a private message). If possible, cutting out (setting via
`g.region`) a small fragment from your study area, and sharing would
allow me to "resolve" this.

Also, please don't post screenshots (if it is not about part of maps or other
visuals). For textual output, please always post the output of your commands
(as in copy and paste) or attach a text file.

For example, I would copy-and-paste the complete output of (or put in a
text file if a specific output of a command is really too long):

# in Bash
for MAP in fuel_model 1hour_moisture live_moisture wind_speed wind_direction slope aspect elevation my_ros.base my_ros.max my_ros.maxdir my_ros.spotdist fire_origin spread_time_observed ;do r.category $MAP ;done

# in Windows
see example in: https://lists.osgeo.org/pipermail/grass-user/2018-June/078526.html

Nikos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20181016/839f3493/attachment.sig>


More information about the grass-user mailing list