Ohjelma lidar regressioestimointiin MINV12-kurssille
A program for regression estimation applying height distributions of ALTM2033 two-pulse lidar data for course MINV12

Ilkka Korpela, 21.03.2006

Ohjelmakoodi ja datat zip-tiedostona (zipped source code and reference tree + polyline data, no lidar points)

Tarkoitus: Idea

Ohjelmalla voi leikata lidar-pisteitä ja maastossa mitattuja puita, jotka osuvat XY-monikulmion sisään ja laskea puiden avulla maastoreferenssiarvon viidelle metsikkömuuttujalle sekä laskea lidar-pisteistä regressioyhtälöillä vastaavat estimaatit. XY-monikulmioita on kahta tyyppiä: The program can be used for selecting lidar points and trees belonging to XY-polygons. Lidar points are used for computing values of five stand variables using models by Suvanto et. al (2005). Trees are used for computing reference values for the same stand variables. There are two types of XY-polygons:

1) Kuvioraja (monikulmio, lista rajapisteiden XY-koordinaatteja) Borders of forest compartments or field plots
2) Koealaruutu (neliö, jolla keskipiste ja neljä rajapistettä XY-koordinaatteineen) Squares representing lidar-plots.

Toiminta lyhyesti Functionality in brief

1) Luetaan tarkka maastomalli (DTM), jonka avulla voidaan laskea maanpintaan nähden normalisoituja korkeuksia. Import an accurate terran model DTM that will be used for computing ground normalized heights for lidar points
2) Luetaan koealan / kuvion kuvioraja-elementti. Import the border-polyline of the plot/compartment
3) Luetaan koealan puutiedot ja haetaan koealan ympäristöön (16 ha) osuvat lidar-pulssit muistiin. Import the reference tree data. Read into memory the lidar data that covers the compartment.
4) Tehdään tasavälinen halutun kokoisten koealaruutujen verkko ja haetaan kullekin täysin kuvion sisään jäävälle ruudulle maastoreferenssipuut ja lidarpisteet, jaettuna FP (first pulse) ja LP (last pulse) pisteiksi. Jos ALTM2033 lidar on tuottanut vain yhden kaiun, se kopioidaan sekä LP että FP pisteeksi. Lasketaan maanpintaan nähden normalisoidut korkeudet ko. pisteille. Create a grid of lidar plot locations in XY with equal spacing in X and Y. Define the size of the square shaped plots (they can overlap). Retrieve for each square plot the lidar points and trees belonging (inclusion) to it. Divide points into first pulse and last pulse returns. If the ALTM2033 data has just one return for a pulse, copy it into first and last pulse points. Compute for each point the ground normalized height with the DTM.
5) Lasketaan Suvanto ym. 2005 tutkimuksen mukaiset selittäjät kullekin ruudulle ruutuun osuneiden FP ja LP pisteiden avulla.  Lasketaan niiden avulla %-pistemalleilla ruudulle tilavuus, ppa, runkoluku, DgM ja HgM.  Lasketaan ruutuun osuneiden puiden avulla referenssiksi tilavuus, ppa, runkoluku, Dg ja Hg (Huom pieni määritelmällinen ero läpimitassa ja pituudessa!)  Tulostetaan lasketut tunnukset per ruutu. The needed explanatory variables are computed from the lidar data and using the models that assume no prior knowledge of the target area the following stand variables are computed for each square-shaped plot: V, G; N, DgM and HgM. With reference trees the same variables are computed for reference values (for DgM and HgM, basal area weighted means Dg and Hg). The results are printed per plot.


Maastomalli: D:\MINV12\HydeLidarDEM.hdr
Kuviorajat    ###_polygon.txt  -tiedostot (24);
Puustodata   ###_treest.txt (24);



Lyhyt seloste vaiheittain  A short walk through

1) Luetaan DTM Import the DTM (File | Read DEM file)   "D:\MINV12\HyderLidarDTM.HDR"
2) Luetaan kuviorajatiedosto Import the compartment polyline (File | Open plot polygon)  Valittu for a field plot "###" choose file ###_polygon.txt -tiedosto, jossa ### on koealan tunnus.
Kuvioraja
Koealalle MMM2 on tehty kuvioraja, joka aukeaa "karttaikkunaan". Plot MMM2 has been drawn  (prepared) a border polyline that captures the trees. A map window opens up with the border and a scale bar.

3) Luetaan puutiedosto Import the reference tree data (File | Open plot treefile and read lidar data) Avataan koealan for plot ### ### puutiedosto file  "###_trees.txt" (oletusarvoisesti d13 on mm-arvoisena) (it is assumed that dbh is stored in mm)

Puukartta
Kuva: Puut piirtyvät karttanäkymään puulajin (väri) ja d13 (ympyrön koko) mukaan koodattuina. Samalla ilmoitetaan, monelleko täydelle hehtaarille data näyttäisi osuvan. Testi tehdään kuviorajan pisteiden avulla. The trees are drawn as circles. Width denotes dbh and color denotes species. Based on the XY-positions of the polyline, the number of "full KKJ-hectares" for which lidar data is needed is notified.

LiDarPisteita
Kuva:  Joka N's lidarpiste tulostetaan kartalle, jotta voi visuaalisesti vakuuttautua lidarin kattavan koealan. For visual check of "the completeness" of the lidar data, every N'th observation is drawn on the map.

4) Määritetään gridi: ruutujen keskipisteiden etäisyys ja ruutujen sivun pituus ovat aliohjelmassa Define_Grid_Click(). Mangle the source code of routine Define_Grid() and define the spacing of the plots and the length of the side of the square. Then run the routine with menu cmmands File | Define grid.
     File | Define grid
     Esim.
     GridSpacingInMeters = 5
     GridWidth = 20
     Ohjelma hakeee kullekin ruudulle puut ja lidarosumat, ja visualisoi homman etenemistä kartalle ruutu kerrallaan. The program finds the lidar points and trees that belong to each cell and the progress of the work is diplayed on the map (speed depends mainly on the amount of lidar data that was read into memory in the previous step):
Ruudutettu_koeala
Kuva: Gridiä kierretään koealan origon suuntaiseksi, jolloin koeala tulee paremmin hyödynnetyksi. Punaiset ristit ovat koealakeskipisteitä, joista ei saatu täyttä ruutua mahtumaan kuvion sisään. The grids are rotated to increase the net area. If a lidar-plot is not completely within the reference compartment (polyline), it is omitted from calculations.

5) Lasketaan puustotunnukset regressiomalleilla ja referenssipuista ruuduile ja tulostetaan tulokset. (File | Calculate forest statistics).  Syntyy C:\DATA\Regression_results.txt tiedosto, jossa on jokaiselle ruudulle [keskipiste.x, keskipiste.y , regressiotilavuus, referenssitilavuus, tilavuuksien erotus, reg_ppa, ref_ppa, ppa_erotus, ja samat kolme runkoluvulle, keskipituudelle sekä keskiläpimitalle]. Compute stand variables with regression functions and with the reference trees (File | Calculate forest statistics). The output file consists of records (one for each square plot) with coordinates and the stand variables and their difference..