Header¶
Header Module
The laspy header module holds the low level laspy.header.Header
class,
which both stores header information during a laspy session, and also provides a
container for moving header data around. Most of the header API is located in
the laspy.header.HeaderManager
class, which holds a laspy.header.Header
instance.
This is accessed from a laspy.file.File
object as laspy.file.File
.header
Additionally, this module holds the VLR and EVLR classes, for regular and extended variable length records as defined in the various LAS specifications.
Finally, this module provides ExtraBytesStruct, which is a frontend for defining additional dimensions in the LAS file via an Extra Bytes type VLR. See the tutorial for an example of this (the LAS specification is also a helpful reference.)
- class laspy.header.ExtraBytesStruct(data_type=0, options=0, name='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', unused=[0, 0, 0, 0], no_data=[0.0, 0.0, 0.0], min=[0.0, 0.0, 0.0], max=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0], offset=[0.0, 0.0, 0.0], description='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')[source]¶
This class provides a frontend for the Extra Bytes Struct as defined in the LAS 1.4 specification. All Arguments are assumed to be default values unless specified - the two really key ones are name and data_type. This structure lives in the VLR_body property of a laspy.header.VLR instance, and multiple ExtraByteStruct records can be present together. Each ExtraBytesStruct instance describes an additional dimension present at the end of each point record.
- __init__(data_type=0, options=0, name='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', unused=[0, 0, 0, 0], no_data=[0.0, 0.0, 0.0], min=[0.0, 0.0, 0.0], max=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0], offset=[0.0, 0.0, 0.0], description='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')[source]¶
Initialize self. See help(type(self)) for accurate signature.
- class laspy.header.EVLR(user_id, record_id, VLR_body, **kwargs)[source]¶
An extended VLR as defined in LAS specification 1.4
- __init__(user_id, record_id, VLR_body, **kwargs)[source]¶
Build the EVLR using the required arguments user_id, record_id, and VLR_body. The user can also specify the reserved and description fields if desired.
- body_summary()¶
Print a summary of parsed_body to the log.
- pack_data()¶
Pack data from parsed_body into VLR_body.
- parse_data()¶
Attempt to read VLR or EVLR body into the parsed_body attribute.
- class laspy.header.Header(file_version=1.2, point_format=0, **kwargs)[source]¶
The low level header class. Header is built from a laspy.util.Format instance, or assumes a default file format of 1.2. Header is usually interacted with via the HeaderManager class, an instance of which readers, writers, and file objects retain a reference of.
- property format¶
The laspy.util.Format instance of the header, builds and stores specifications for the data fields belonging to the header. Assigning to format will re-format the header.
- class laspy.header.HeaderManager(header, reader)[source]¶
HeaderManager provides the public API for interacting with header objects. It requires a Header instance and a reader/writer instance. HeaderManager instances are referred to in reader/writer/file object code as header.
- property data_format_id¶
Returns the number of user-defined header records in the header.
- property data_offset¶
The offset to the point data in the file. This can not be smaller then the header size + VLR length.
- property data_record_length¶
The length of each point record.
- property date¶
The header’s date from a
datetime.datetime
instance.- Parameters
value –
datetime.datetime
instance or none to use the current time
>>> t = datetime.datetime(2008,3,19) >>> hdr.date = t >>> hdr.date datetime.datetime(2008, 3, 19, 0, 0)
Note
LAS files do not support storing full datetimes in their headers, only the year and the day number. The conversion is handled for you if you use
datetime.datetime
instances, however.
- property file_signature¶
The file signature for the file. Should always be LASF
- property file_source_id¶
The file source ID for the file.
- property global_encoding¶
Global encoding for the file.
From the specification:
This is a bit field used to indicate certain global properties about the file. In LAS 1.2 (the version in which this field was introduced), only the low bit is defined (this is the bit, that if set, would have
- property header_size¶
The header size for the file. You probably shouldn’t touch this.
- property major_version¶
The major version for the file, always 1
- property max¶
The maximum values of [x, y, z] for the data in the file.
- property min¶
The minimum values of [x, y, z] for the data in the file.
>>> hdr.min [0.0, 0.0, 0.0] >>> hdr.min = [33452344.2333, 523442.344, -90.993] >>> hdr.min [33452344.2333, 523442.34399999998, -90.992999999999995]
- property minor_version¶
The minor version for the file.
- property offset¶
The offset factors in [x, y, z] for the point data.
- From the specification:
The offset fields should be used to set the overall offset for the point records. In general these numbers will be zero, but for certain cases the resolution of the point data may not be large enough for a given projection system. However, it should always be assumed that these numbers are used. So to scale a given X from the point record, take the point record X multiplied by the X scale factor, and then add the X offset.
- Coordinates are calculated using the following formula(s):
x = (x_int * x_scale) + x_offset
y = (y_int * y_scale) + y_offset
z = (z_int * z_scale) + z_offset
>>> hdr.offset [0.0, 0.0, 0.0] >>> hdr.offset = [32, 32, 256] >>> hdr.offset [32.0, 32.0, 256.0]
- property padding¶
The number of bytes between the end of the VLRs and the beginning of the point data.
- property point_return_count¶
The histogram of point records by return number.
- property project_id¶
ProjectID for the file. laspy does not currently support setting this value from Python, as it is the same as
laspy.header.Header.guid
. Use that to manipulate the ProjectID for the file.- From the specification:
The four fields that comprise a complete Globally Unique Identifier (GUID) are now reserved for use as a Project Identifier (Project ID). The field remains optional. The time of assignment of the Project ID is at the discretion of processing software. The Project ID should be the same for all files that are associated with a unique project. By assigning a Project ID and using a File Source ID (defined above) every file within a project and every point within a file can be uniquely identified, globally.
- property scale¶
- The scale factors in [x, y, z] for the point data.
From the specification: The scale factor fields contain a double floating point value that is used to scale the corresponding X, Y, and Z long values within the point records. The corresponding X, Y, and Z scale factor must be multiplied by the X, Y, or Z point record value to get the actual X, Y, or Z coordinate. For example, if the X, Y, and Z coordinates are intended to have two decimal point values, then each scale factor will contain the number 0.01
- Coordinates are calculated using the following formula(s):
x = (x_int * x_scale) + x_offset
y = (y_int * y_scale) + y_offset
z = (z_int * z_scale) + z_offset
- property schema¶
The header format for the file. Supports .xml and .etree methods.
- property software_id¶
The software ID for the file
- property system_id¶
The system ID for the file
- property version¶
The version as a dotted string for the file (ie, ‘1.0’, ‘1.1’, etc)
- property vlrs¶
Get/set the VLR`’s for the header as a list VLR’s are completely overwritten, so to append a VLR, first retreive the existing list with get_vlrs and append to it.
- class laspy.header.VLR(user_id, record_id, VLR_body, **kwargs)[source]¶
An object to create/read/store data from LAS Variable Length Records. Requires three arguments: (user_id, string[16]), (record_id, int2), (VLR_body, any data with len < ~65k)
- __init__(user_id, record_id, VLR_body, **kwargs)[source]¶
Build the VLR using the required arguments user_id, record_id, and VLR_body the user can also specify the reserved and description fields here if desired.
- body_summary()¶
Print a summary of parsed_body to the log.
- pack_data()¶
Pack data from parsed_body into VLR_body.
- parse_data()¶
Attempt to read VLR or EVLR body into the parsed_body attribute.