[GRASS-user] Speeding up bash script

andrew haywood ahaywood3 at gmail.com
Thu Aug 28 19:00:29 EDT 2008

Hi Wesley,

I have recently analysed some lidar data in GRASS and have used Hamish's
r.in.xyz module. Its a pretty useful tool to bin up lidar data.


On 8/28/08, Maciej Sieczka <tutey at o2.pl> wrote:
> Wesley Roberts pisze:
> 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.
> Wesley,
> Each db.execute call is expensive (v.db.update is a wrapper for
> db.execute).
> Remove v.db.update from the loop. Replace it with a command that
> will create corresponding SQL statements, and store them in a text file.
> Outside the loop pipe the file into db.execute. This will do the whole
> update in one run. Should save plenty of time. There's an example in
> db.execute manual.
> You can also use "v.univar -g" - shell script output style. It is easier
> to parse. Thus instead:
>  v.univar map=b_sam_$x type=point column=dbl_5 layer=1 > temp_file
>  a=`sed -n '5p' temp_file | awk '{print $2}'
> you can put:
>  eval `v.univar -g map=b_sam_$x type=point column=dbl_5 layer=1`
> and then variable 'max' automagically stores your maximum value.
> Maciek
> --
> Maciej Sieczka
> www.sieczka.org
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20080829/774502b3/attachment.html

More information about the grass-user mailing list