[GRASS-user] How to grep basic statistics from a vector ascii (x, y, z) file and export in a new ascii?

A friend works with LIDAR data. He needs to write a program with which
he extracts (from an vector ASCII x,y,z file) the row containing the
maximum z (height) and write a new vector ASCII containing the result.

(He writes in C++)

Since he deals with lots of ASCII files he needs to batch this job.

How about doing this in GRASS? With R maybe?

Thank you,

Nikos

--
Nikos Alexandris
.
Department of Remote Sensing & Landscape Information Systems
Faculty of Forestry & Environmental Sciences, Albert-Ludwigs-University Freiburg
.
Tel. +49 (0) 761 203 3697 / Fax. +49 (0) 761 203 3701 / Skype: Nikos.Alexandris
.
Address: Tennenbacher str. 4, D-79106 Freiburg i. Br., Germany

On Jan 5, 2008 5:17 PM, Nikos Alexandris
<nikos.alexandris@felis.uni-freiburg.de> wrote:

A friend works with LIDAR data. He needs to write a program with which
he extracts (from an vector ASCII x,y,z file) the row containing the
maximum z (height) and write a new vector ASCII containing the result.

(He writes in C++)

Since he deals with lots of ASCII files he needs to batch this job.

How about doing this in GRASS? With R maybe?

It would be good to extend v.univar to also analyze the geometry
statistics. I was seeking for the same functionality recently.

Markus

you could use R with the Rgdal [1] package. You read the LIDAR file
and then simply a function like this:

import your data attirubting them to "your_Dataframe" with something like:

# your_Dataframe<-readGDAL(filename,drivername)

You could retrieve the drivernames with gdalDrivers()

# row_MAX<-your_Dataframe[your_Dataframe$z==max(your_Dataframe$z),]

row_MAX is now a vector containing the coordinates and the z value of
the mazimum z.

Giovanni

[1] http://cran.r-project.org/src/contrib/Descriptions/rgdal.html

2008/1/5, Markus Neteler <neteler@osgeo.org>:

On Jan 5, 2008 5:17 PM, Nikos Alexandris
<nikos.alexandris@felis.uni-freiburg.de> wrote:
> A friend works with LIDAR data. He needs to write a program with which
> he extracts (from an vector ASCII x,y,z file) the row containing the
> maximum z (height) and write a new vector ASCII containing the result.
>
> (He writes in C++)
>
> Since he deals with lots of ASCII files he needs to batch this job.
>
> How about doing this in GRASS? With R maybe?

It would be good to extend v.univar to also analyze the geometry
statistics. I was seeking for the same functionality recently.

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

Your task sounds like it would be best done by a small script or C
program. Just read the data in a line-at-a-time and check if the
current line is larger than the previously stored line. At the end of
the file, print out the largest line (to a file if you have multiple
results to store). Probably 5 or 6 lines of Perl/Python at most and
you would be able to read arbitrarily huge files (millions of rows).
Most other solutions would introduce complexity or unnecessary
overhead. For lidar data, you may not have enough RAM to hold the
whole file in memory and the last thing you want to do is attach
topology to each point before you manipulate it.

Thank you all for your replies!

On Sat, 2008-01-05 at 15:12 -0800, David Finlayson wrote:

Your task sounds like it would be best done by a small script or C
program. Just read the data in a line-at-a-time and check if the
current line is larger than the previously stored line. At the end of
the file, print out the largest line (to a file if you have multiple
results to store). Probably 5 or 6 lines of Perl/Python at most and
you would be able to read arbitrarily huge files (millions of rows).
Most other solutions would introduce complexity or unnecessary
overhead. For lidar data, you may not have enough RAM to hold the
whole file in memory and the last thing you want to do is attach
topology to each point before you manipulate it.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Nikos Alexandris
.
Department of Remote Sensing & Landscape Information Systems
Faculty of Forestry & Environmental Sciences, Albert-Ludwigs-University Freiburg
.
Tel. +49 (0) 761 203 3697 / Fax. +49 (0) 761 203 3701 / Skype: Nikos.Alexandris
.
Address: Tennenbacher str. 4, D-79106 Freiburg i. Br., Germany

On Jan 6, 2008 12:12 AM, David Finlayson <dfinlayson@usgs.gov> wrote:

Your task sounds like it would be best done by a small script or C
program. Just read the data in a line-at-a-time and check if the
current line is larger than the previously stored line. At the end of
the file, print out the largest line (to a file if you have multiple
results to store). Probably 5 or 6 lines of Perl/Python at most and
you would be able to read arbitrarily huge files (millions of rows).
Most other solutions would introduce complexity or unnecessary
overhead. For lidar data, you may not have enough RAM to hold the
whole file in memory and the last thing you want to do is attach
topology to each point before you manipulate it.

Possibly code from r.in.xyz could be recycled for v.univar to operate
on the geometry. I also don't think that you could handle this in R, so
a C implementation is needed.

Markus

That works for an ASCII file, but I was thinking to generalize the use
cases. Ok, passing through R would require to much RAM, but anyway I
need to use a driver to handle the binary rasters (I'm saying this
because I have a similar task but with ArcINFO GRID files).
What would you do?

2008/1/6, Markus Neteler <neteler@osgeo.org>:

On Jan 6, 2008 12:12 AM, David Finlayson <dfinlayson@usgs.gov> wrote:
> Your task sounds like it would be best done by a small script or C
> program. Just read the data in a line-at-a-time and check if the
> current line is larger than the previously stored line. At the end of
> the file, print out the largest line (to a file if you have multiple
> results to store). Probably 5 or 6 lines of Perl/Python at most and
> you would be able to read arbitrarily huge files (millions of rows).
> Most other solutions would introduce complexity or unnecessary
> overhead. For lidar data, you may not have enough RAM to hold the
> whole file in memory and the last thing you want to do is attach
> topology to each point before you manipulate it.

Possibly code from r.in.xyz could be recycled for v.univar to operate
on the geometry. I also don't think that you could handle this in R, so
a C implementation is needed.

Markus

All,

To print the line from an ASCII file with the maximum z-value, you could do

sort -n -k3 input_file.txt | tail -1

Bruce

On Jan 6, 2008 7:56 AM, G. Allegri <giohappy@gmail.com> wrote:

That works for an ASCII file, but I was thinking to generalize the use
cases. Ok, passing through R would require to much RAM, but anyway I
need to use a driver to handle the binary rasters (I'm saying this
because I have a similar task but with ArcINFO GRID files).
What would you do?

2008/1/6, Markus Neteler <neteler@osgeo.org>:

> On Jan 6, 2008 12:12 AM, David Finlayson <dfinlayson@usgs.gov> wrote:
> > Your task sounds like it would be best done by a small script or C
> > program. Just read the data in a line-at-a-time and check if the
> > current line is larger than the previously stored line. At the end of
> > the file, print out the largest line (to a file if you have multiple
> > results to store). Probably 5 or 6 lines of Perl/Python at most and
> > you would be able to read arbitrarily huge files (millions of rows).
> > Most other solutions would introduce complexity or unnecessary
> > overhead. For lidar data, you may not have enough RAM to hold the
> > whole file in memory and the last thing you want to do is attach
> > topology to each point before you manipulate it.
>
> Possibly code from r.in.xyz could be recycled for v.univar to operate
> on the geometry. I also don't think that you could handle this in R, so
> a C implementation is needed.
>
> Markus
>
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Bruce Raup
http://cires.colorado.edu/~braup/

Unix rocks.

Markus Neteler wrote:

It would be good to extend v.univar to also analyze the geometry
statistics. I was seeking for the same functionality recently.

'v.info -g' ?

Hamish

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ