laspy.point.record module¶
Contains the classes that manages Las PointRecords Las PointRecords are represented using Numpy’s structured arrays, The PointRecord classes provide a few extra things to manage these arrays in the context of Las point data
- class laspy.point.record.DimensionNameValidity(value)[source]¶
Bases:
Enum
Helper class to make the return value of PackedPointRecord.validate_dimentsion_name more expressive.
- Valid = 1¶
- Unsupported = 2¶
- Invalid = 3¶
- class laspy.point.record.PackedPointRecord(data: ndarray, point_format: PointFormat)[source]¶
Bases:
object
In the PackedPointRecord, fields that are a combinations of many sub-fields (fields stored on less than a byte) are still packed together and are only de-packed and re-packed when accessed.
This uses of less memory than if the sub-fields were unpacked
>>> #return number is a sub-field >>> from laspy import PointFormat, PackedPointRecord >>> packed_point_record = PackedPointRecord.zeros(10,PointFormat(0)) >>> return_number = packed_point_record['return_number'] >>> return_number <SubFieldView([0 0 0 0 0 0 0 0 0 0])> >>> return_number[:] = 1 >>> np.alltrue(packed_point_record['return_number'] == 1) True
- property point_size¶
Returns the point size in bytes taken by each points of the record
- Returns:
The point size in byte
- Return type:
- static zeros(point_count, point_format)[source]¶
Creates a new point record with all dimensions initialized to zero
- Parameters:
point_format (PointFormat) – The point format id the point record should have
point_count (int) – The number of point the point record should have
- Return type:
- static empty(point_format)[source]¶
Creates an empty point record.
- Parameters:
point_format (laspy.PointFormat) – The point format id the point record should have
- Return type:
- classmethod from_point_record(other_point_record: PackedPointRecord, new_point_format: PointFormat) PackedPointRecord [source]¶
Construct a new PackedPointRecord from an existing one with the ability to change to point format while doing so
- copy_fields_from(other_record: PackedPointRecord) None [source]¶
Tries to copy the values of the current dimensions from other_record
- copy() PackedPointRecord [source]¶
- memoryview() memoryview [source]¶
- validate_dimension_name(key: str) DimensionNameValidity [source]¶
Given a name of a dimension this validates it.
- class laspy.point.record.ScaleAwarePointRecord(array, point_format, scales, offsets)[source]¶
Bases:
PackedPointRecord
A ScaleAwarePointRecord is a point record that knows the scales and offets to use, and is thus able to get and set the scaled x, y, z coordinates
To create one, use
ScaleAwarePointRecord.zeros()
orScaleAwarePointRecord.empty()
- static zeros(point_count, *, point_format=None, scales=None, offsets=None, header=None)[source]¶
Creates a new point record with all dimensions initialized to zero
Examples
>>> record = ScaleAwarePointRecord.zeros( ... 5, point_format=PointFormat(3), scales=[1.0, 1.0, 1.0], offsets=[0.1, 0.5, 17.5]) >>> len(record) 5
>>> import laspy >>> hdr = laspy.LasHeader() >>> record = ScaleAwarePointRecord.zeros(5, header=hdr) >>> len(record) 5
>>> hdr = laspy.LasHeader() >>> record = ScaleAwarePointRecord.zeros(5, header=hdr, scales=[1.0, 1.0, 1.0]) Traceback (most recent call last): ValueError: header argument is mutually exclusive with point_format, scales and offets
>>> record = ScaleAwarePointRecord.zeros(5, point_format=PointFormat(3)) Traceback (most recent call last): ValueError: You have to provide all 3: point_format, scale and offsets
- static empty(point_format=None, scales=None, offsets=None, header=None)[source]¶
Creates an empty point record.