User Tools

Site Tools


wiki:grass_rs_gui

Burned area mapping exercise

GRASS can be used to perform remote sensing image analysis in terms of preprocessing, classification and validation. The image analysis commands start with the suffix “ i. ” (e.g., i.class , i.maxlik). They can be run in the bash shell and can be applied to any grass raster layer.
The commands are listed and described in the Reference Manual .

Image classification

The following table summarizes the most important GRASS commands for Classification.
^ ^radiometric unsupervised^radiometric supervised^radiometric supervised^radiometric & geometric supervised^ |Image Preprocessing|r.seg|r.seg|r.seg|r.seg| |Preprocessing|i.cluster|i.class (monitor digitizing)|i.gensig (using training maps)|i.gensigset(using training maps)| |Classification|i.maxlik|i.maxlik|i.maxlik| i.smap| |Remarks|automated from image statistics|requires training pixel collection|requires training pixel collection|requires training pixel collection|
* The preprocessing phase captures spectral signatures for each land cover class for later use by the classifier algorithm. * The classification phase performs the classification based on the signatures collected in the previous step.
===== Using WELD data for burned area mapping =====
In order to understand the structure architecture of GRASS and the main modules and commands you can download the Introduction to GRASS presentation and see the Hands on GRASS: Geographic Resources Analysis Support System page. ==== Create New Mapset in GRASS ====
Start Grass grass -wxpython Create new grass database, location and mapset using the grass Location Wizard button. Insert the options as reported in the below screenshots.

|||

Enter PROJ.4 parameters string under the “Choose method for specifying georeferencing parameters:“
+proj=aea +lat1=55 +lat2=65 +lat0=50 +lon0=-154 +x0=0 +y0=0 +nodefs +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000 +tometer=1

|||

|||

At this point the GIS Data Directory, the Project location and the Accessible mapset have been created and it is possible to start grass by the Start GRASS button.
The following screenshots show the GRASS wxpython GUI. It possible to navigate in the tools bar and select the appropriate window module. Each module is a graphical tool of a command with its options. At the bottom of each module you can see the command line syntax that you can use to create a script routine.

||

==== Importing data ====
The created mapset is an empty environment where we can import the data:
Band1TOAREF.TIF Band2TOAREF.TIF Band3TOAREF.TIF Band4TOAREF.TIF Band5TOAREF.TIF Band7TOAREF.TIF
stored in the /home/user/ost4sem/exercise/welddataprocessing/x6JIatZlSUMMER2008

Open the Import raster data window as:
> File > Import Raster Data > Common Import Formats
and select the Band1TOAREF.TIF Band2TOAREF.TIF Band3TOAREF.TIF Band4TOAREF.TIF Band5TOAREF.TIF Band7TOAREF.TIF
file as reported in the following screenshot.

||

==== Create RGB color map ====
Open the i.landsat.rgb window by:
> Immagery > Manage immage colors > Color balance for RGB (command i.landsat.rgb).
and select the bands as reported in the following screenshots.

||
Open the r.composite window by:
> Raster > Manage colors > Create RGB (command r.composite)
and select the bands as reported in the left side of following screenshots. Visualize the results by the GRASS wxpython GUI opening Band432TOAREF (right side screenshots).

| ||

==== Group the bands ====
From this point is much easier to use the command line. Copy the line and insert it in the terminal. i.group group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup input=Band1TOAREF,Band2TOAREF,Band3TOAREF,Band4TOAREF,Band5TOAREF,Band7TOAREF ==== Unsupervised classification ====
Generate unsupervised statistics for 7 classes (you could select more classes, fewer tends not to work so well for these data): <code bash> i.cluster group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxlClust classes=8 sample=10,10 reportfile=Band432TOAREFreport.txt </code> Create the unsupervised classified image: <code bash> g.remove rast=maxlikClustmap i.maxlik group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxlClust class=maxlikClustmap
</code> Visualize the results using the GRASS wxpython GUI opening maxlikClust
map. Compare visually the classified map and the RGB layer.
As you can see, the unsupervised classification classifies the burned area into several classes.

||

Let's try again now but with a supervised classifier to see if we can getter better results.

==== Supervised classification ====
For supervised classification you will need to create a shape file containing polygons where each polygon locates pixels that you think represent the different classes in the image (e.g., burned, unburned, cloud etc.) - these will be used as training data by the supervised classification algorithm.

Create a training class polygon using qgis or GRASS wxpython. See the procedure in Editing and creating a vector in QGIS

If you cannot create it use ~/ost4sem/exercise/welddataprocessing/classburnedexample.shp by importing it into GRASS as: <code bash> g.remove vect=class ; v.db.droptable map=class v.in.ogr -o dsn=~/ost4sem/exercise/welddataprocessing/shp/classburned.shp output=class minarea=0.0001 snap=-1 </code> Then convert the training class polygon to raster format: <code bash> v.to.rast in=class out=class use=attr column=burned labelcol=burned –o </code> Visualize the training class polygon raster using the GRASS wxpython GUI.
Now perform supervised classification with either of the two following methods.

== Supervised classification using maximum-likelihood discriminant analysis ==
Generate statistics from the training areas, to be used with the i.maxlik command. <code bash> i.gensig group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxl trainingmap=class </code> Perform the classification <code bash> i.maxlik group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxl class=maxlikmap –o </code> == Supervised classification using sequential maximum a posteriori (SMAP) estimation ==
Generate statistics from the training areas, to be used with the i.smap command. This is a long process (1hour !), so run it during your break. <code bash> i.gensigset group=Band
MultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4smap training=class </code> Perform the classification <code bash> i.smap group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4smap out=smapmap –o </code>
You can visualize the maxlikmap and smapmap rasters using the GRASS wxpython GUI.

For example, the following screenshots show maxlikmap (left) and smapmap (right)

|| |
==== Stand alone script ====
The same exercise can be done by a stand alone script.
Create a new grass location alaska2. <code bash> cd ~/ost4sem/exercise/welddataprocessing/x6JIatZlSUMMER2008 bash ~/ost4sem/exercise/basicadvgrass/createlocation.sh Band1TOAREF.TIF alaska2 /home/user/ost4sem/exercise/welddataprocessing </code> Start grass manually. <code bash> grass64 -wxpython /home/user/ost4sem/exercise/welddataprocessing/alaska2/PERMANENT </code> Import all the data by a loop: <code bash> for file in *TOA_REF.TIF ; do RAST=basename $file .TIF r.in.gdal in=$file out=$RAST done </code> Run the previous steps line by line and see the results with the GRASS wxpython GUI. <code bash> i.group group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup input=Band1TOAREF,Band2TOAREF,Band3TOAREF,Band4TOAREF,Band5TOAREF,Band7TOAREF i.cluster group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxlClust classes=8 sample=10,10 reportfile=Band432TOAREF_report.txt g.remove rast=maxlikClustmap i.maxlik group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxlClust class=maxlikClustmap
g.remove vect=class ; v.db.droptable map=class v.in.ogr -o dsn=~/ost4sem/exercise/welddataprocessing/shp/classburned.shp output=class minarea=0.0001 snap=-1 v.to.rast in=class out=class use=attr column=burned labelcol=burned –o i.gensig group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxl trainingmap=class i.maxlik group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4maxl class=maxlik_map –o i.gensigset group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4smap training=class i.smap group=BandMultiTOAREFgroup subgroup=BandMultiTOAREFsubgroup sig=BandMultiTOAREFsig4smap out=smap_map –o </code>

wiki/grass_rs_gui.txt · Last modified: 2017/12/05 22:53 (external edit)