I am using liblas in Python to read, manipulate and write a special point format *.las
. I have a string as
s = "309437.95 6959999.84 118.98 16 1 1 0 0 1 0 112.992 5.9881"
Where the first is the X
, the second the Y
, the third element the Z
etc.
Using Liblas, I create an empty liblas.point.Point
object
>>> pt = liblas.point.Point()
>>> pt
<liblas.point.Point object at 0x0000000005194470>
After that I need to fill this object because is empty.
>>> pt.x, pt.y,pt.z
(0.0, 0.0, 0.0)
probably using
>>> pt.get_x
<bound method Point.get_x of <liblas.point.Point object at 0x0000000005194470>>
I wish to say thanks for all help and suggestion, I really need to solve this step.
from suggestion of Martijn Pieters
s = "%s %s %s" % (s, value, nh)
>>> s
'309437.95 6959999.84 118.98 16 1 1 0 0 1 0 112.992 5.9881'
# create a liblas.point.Point
pt = liblas.point.Point()
pt.x = float(s.split()[0])
pt.y = float(s.split()[1])
pt.z = = float(s.split()[11]) # the new Z value
pt.intensity = = int(s.split()[3])
pt.return_number= int(s.split()[4])
pt.number_of_returns = int(s.split()[5])
pt.scan_direction = int(s.split()[6])
pt.flightline_edge = int(s.split()[7])
pt.classification = int(s.split()[8])
pt.scan_angle = int(s.split()[9])
There are
raw_x
,raw_y
andraw_z
properties on a Point object; simply set those:There are also
x
,y
andz
properties; it is not immediately clear from the source code what the difference is between the two types:but the library can produce these objects directly from a .las file for you, can't it? The
File
class you had trouble with before certainly does return these objects already.And since you updated to show some code, here is a more readable version of that: