[Liblas-devel] Ground Modeling with RAW LiDAR and libLAS

Peter Tittmann pwtittmann at ucdavis.edu
Fri Mar 4 14:35:54 EST 2011


All,

I wrote some python to  pipe las2txt to  GRASS's r.in.xyz on using
subprocess which is what most of the GRASS python scripts use. Its not very
sophisticated at all but seems to work decently well however I suspect
Howard's point about it not being much better than the text file approach is
true. Its based on the GRASS LIDAR wiki page(
http://grass.osgeo.org/wiki/LIDAR): Heres an example:

from liblas import file, header
import subprocess as sub
import grass.script as grass

def run(cmd, **kwargs):
    grass.run_command(cmd, quiet = True, **kwargs)

path='../data/las/ucd_01.las'
dbname='ucd_01.las'
h=file.File(path).header
run("g.region", e=h.max[0], w=h.min[0], s=h.min[1], n=h.max[1])
pts=sub.Popen('las2txt -i %s --parse xyz --delimiter "|" --keep-classes 2
--stdout'%path, shell=True, stdout=sub.PIPE)
mkInRast=grass.feed_command("r.in.xyz", input="-", output=dbname,
method='mean')
mkInRast.stdin.write(pts.communicate()[0])
mkInRast.stdin.close()
mkInRast.wait()

#this stuff is based on the wiki page for interpolating/filtering the
resulting GRASS dataset

run("r.to.vect", flags='z', input=dbname, output=dbname+'_pt',
feature='point')
run("v.surf.rst", layer='0', input=dbname+'_pt', elev= dbname+'_rst')
run("g.remove", vect='%s_pt'%dbname)
run("g.remove", rast=dbname)

Best,

Peter


On Fri, Mar 4, 2011 at 11:10 AM, Howard Butler <hobu.inc at gmail.com> wrote:

>
> On Mar 4, 2011, at 12:24 PM, Stuart Edwards wrote:
>
> >
> > On Mar 4, 2011, at 9:27 AM, Howard Butler wrote:
> >
> >>
> >> On Mar 4, 2011, at 8:29 AM, francesco wrote:
> >>
> >>> I use GRASS quite a lot, but always thought that it would be slow on
> vector points. I know Brovelli and her team developed some modules, I'll
> check on that. Good idea to use LibLAS as "driver" to turn LAS to xyz.
> >>
> >> It would be much, much, much faster if someone wrote some glue between
> libLAS and GRASS (proposed here quite a while ago, but still not done <
> http://lists.osgeo.org/pipermail/grass-dev/2008-May/037687.html>).  I
> would guess it would be an order of magnitude faster to ingest data if you
> didn't have to go through text formats to do it.
> >
> > This may be possible since Liblas has a las2ogr tool and GRASS uses ogr
> for vector input - seems there's an opportunity to script output from the
> former and pipe it as  input to v.in.ogr ?  Beyond my skills unfortunately
> ....
>
> that's not really much better.  What needs to happen is for someone to
> write some code in GRASS that utilizes libLAS directly.  Surely a
> manpower/desire thing.
>
> Howard_______________________________________________
> Liblas-devel mailing list
> Liblas-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/liblas-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/liblas-devel/attachments/20110304/fa9daed4/attachment.html


More information about the Liblas-devel mailing list