Dear Grass'ers

I have written a bash script to extract the maximum LiDAR height value within a 
predefined sample site (Vector with 314 sample locations each 10m squared). The 
script is below. Essentially I use v.extract to select one of my 314 sample 
sites (Flight_sample2). This temporary vector is then used to select all LiDAR 
points falling within its boundaries using v.select. Following this I use 
v.univar to calculate summary statistics of the points selected which is then 
written to temp_file. sed and awk are then used to extract the maximum height 
value which is then used to update (v.db.update) the original flight sample 
file. The script does exactly what it is suppose to do and I am chuffed with 
the result, however, it does take an enormous amount of time. For my largest 
area, over 200 samples it took almost two whole days (running non-stop) to 
complete the task. I may need to calculate additional summary statistics at a 
later date and would like to speed up the operation.

Can anyone suggest a faster way to do this? I am a 'noob' when it comes to bash 
scripts and programming in general so any additional help would be greatly 
appreciated. Additionally, I am using the dbf driver.

Many thanks
Wesley

**********************************************************************************************************************************************************************

#!/bin/bash
x=61
a=0
while [ $x -le 284 ]
do
        v.extract [EMAIL PROTECTED] output=sam_$x type=area layer=1 new=-1 
where=SAM=$x --overwrite
        v.select [EMAIL PROTECTED] atype=point alayer=1 binput=sam_$x 
btype=area blayer=1 output=b_sam_$x operator=overlap --overwrite
        v.univar map=b_sam_$x type=point column=dbl_5 layer=1 > temp_file
        a=`sed -n '5p' temp_file | awk '{print $2}'`
        echo "$x"
        echo "Maximum Lidar point height for this sample location sam_$x is: $a"
        v.db.update map=Flight_sample2 layer=1 column=mx_LR value=$a 
where=SAM=$x
        g.remove vect=b_sam_$x,sam_$x
        echo "Sample $x from area One has now been processed"
        x=$(( $x + 1 ))
done

**********************************************************************************************************************************************************************

-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.

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

Reply via email to