Monday, March 5, 2012

Counting trees using segmentation and vectorization in SAGA Gis

Digital surface models (DSM) and digital terrain models (DTM) derived from LiDAR datasets can be used to count the number of trees in an area. There are many methods available, some more complex than others. Here is another example of doing a simple tree count using SAGA GIS' Watershed Segmentation algorithm followed by the Vectorization function. The general steps are:

  1. Load in the DSM and DTM grid datasets
  2. Calculate the canopy heights
  3. Smooth the canopy heights grid
  4. Segment the canopy heights
  5. Remove low canopy heights
  6. Convert the segments to vector polygons


Load the DSM and DTM grid datasets
  1. Start SAGA GIS. Load the DSM ArcGrid file e.g. C:\data\dsm.asc.
  2. Load the DTM ArcGrid file e.g. C:\data\dtm.asc.
Calculate the canopy heights
  1. Select Modules | Grid | Calculus | Grid Difference.

    The Grid Difference dialog box appears.
  2. In the Grid system field, choose the system of the source datasets, e.g. 683x 683y; 312480x 51952717y.
  3. In the A field, choose the digital surface model grid, e.g. dsm.
  4. In the B field, choose the digital terrain model grid, e.g. dtm.
  5. Click Okay.

    The canopy height grid is created.


Smooth the canopy heights
  1. Select Modules | Grid | Filter | Gaussian Filter.

    The Gaussian Filter dialog box appears.
  2. In the Grid system field, choose the system of the source grid e.g. 683x 683y; 312480x 51952717y.
  3. In the Grid field, choose the canopy height grid, e.g. Difference (A-B).
  4. In the output Filtered Grid field, choose Create.
  5. In the Search Radius field, choose a value to approximate the tree radius e .g. 5.
  6. Click Okay.

    The smoothed canopy height grid is created.
Segment the smoothed canopy heights

  1. Select Modules | Imagery | Segmentation | Watershed Segmentation.

    The Watershed Segmentation dialog box appears.
  2. In the Grid system field, choose the grid system of the smoothed grid layer.
  3. In the source Grid field, choose the smoothed grid layer e.g. Difference (A-B) [Gaussian Filter].
  4. In the Output field, choose Seed.
  5. Make sure the Method is set to Maxima.
  6. Click Okay.

    The canopy heights grid layer is segmented according to maximum heights.

Apply a height break limit (removing segments below a certain height)

  1. Select Modules | Grid | Calculus | Grid Calculator.

    The Grid Calculator dialog box appears.
  2. In the Grid system field, choose the system of the segmented layer.
  3. In the Grids field, click the browse button. In the Grids dialog box that pops up, double click on the segmented  grid layer e.g. "Difference (A-B) [Gaussian Filter][Segments]". Click Okay.
  4. In the Formula field, type in the following: ifelse(lt(a,5),-99999,a).

    Note: if the grid value is less than 5, then change the grid value to voids (-99999).
  5. Click Okay.

    The grid layer with no values below the height break limit is created.
Convert the segments into vectors
  1. Select Modules | Shapes | Grid | Vectorization | Vectorising Grid Classes.

    The Vectorising Grid Classed dialog box appears.
  2. In the Grid system field, choose the system of the previously created grid layer.
  3. In the Grid field, choose the grid layer created in the previous step e.g. "Calculation [ifelse(lt(a,5),-99999,a)]".



  4. Click Okay.

    The vector polygon layer is created.
  5. Select the shape polygon layer in the Data tab. Then click the Description tab.

    The number of shapes shows the approximate count of the number of trees above a height break limit.




    The polygons can be displayed as table attribute records as shown below.

3 comments:

Ezit said...

Hey there!

Thank you so much for the knowledge shared. It helps me a lot.I have one question. Referring to the final output, values in the attribute table represent canopy height, am I right? I'm wondering if those values are the information for canopy/ crown size. Thanks!

Regards,
Ezit

dominoc925 said...

Hi Ezit
the value should be the highest watershed height within the segmented polygon i.e. the canopy height in this case. An approximation of the crown size would be the radius/diameter/width of the segmented polygon.

Ezit said...

Ok, got it! Thank you very much, sir. Once again, thanks a million for this very informative blog. =)