API Documentation¶
Re-exported functions¶
laspy.read¶
- laspy.read(source, closefd=True, laz_backend=(), decompression_selection: ~laspy._compression.selection.DecompressionSelection = DecompressionSelection.None)¶
Entry point for reading las data in laspy
Reads the whole file into memory.
>>> las = read_las("tests/data/simple.las") >>> las.classification <SubFieldView([1 1 1 ... 1 1 1])>
- Parameters:
source (str or io.BytesIO) – The source to read data from
laz_backend (Optional, the backend to use when the file is as LAZ file.) – By default laspy will find the backend to use by itself. Use if you want a specific backend to be used
closefd (bool) – if True and the source is a stream, the function will close it after it is done reading
decompression_selection (DecompressionSelection,) – see
laspy.open()
- Returns:
The object you can interact with to get access to the LAS points & VLRs
- Return type:
laspy.LasData
New in version 2.4: The
decompression_selection
parameter.
laspy.open¶
- laspy.open(source, mode='r', closefd=True, laz_backend=None, header=None, do_compress=None, encoding_errors: str = 'strict', read_evlrs: bool = True, decompression_selection: ~laspy._compression.selection.DecompressionSelection = DecompressionSelection.None) Union[LasReader, LasWriter, LasAppender] ¶
The laspy.open opens a LAS/LAZ file in one of the 3 supported mode:
“r” => Reading => a
laspy.LasReader
will be returned“w” => Writing => a
laspy.LasWriter
will be returned“a” => Appending => a
laspy.LasAppender
will be returned
When opening a file in ‘w’ mode, a header (
laspy.LasHeader
) is required>>> with open_las('tests/data/simple.las') as f: ... print(f.header.point_format.id) 3
>>> f = open('tests/data/simple.las', mode='rb') >>> with open_las(f,closefd=False) as flas: ... print(flas.header) <LasHeader(1.2, <PointFormat(3, 0 bytes of extra dims)>)> >>> f.closed False >>> f.close() >>> f.closed True
>>> f = open('tests/data/simple.las', mode='rb') >>> with open_las(f) as flas: ... las = flas.read() >>> f.closed True
- Parameters:
source (str or bytes or io.BytesIO) – if source is a str it must be a filename
mode (Optional, the mode to open the file:) –
“r” for reading (default)
”w” for writing
”a” for appending
laz_backend (Optional, laspy.LazBackend, the LAZ backend to use to handle decompression/compression) – By default available backends are detected, see LazBackend to see the preference order when multiple backends are available
header (The header to use when opening in write mode.) –
do_compress (optional, bool, only meaningful in writing mode:) –
None (default) guess if compression is needed using the file extension or if a laz_backend was explicitely provided
True compresses the file
False do not compress the file
closefd (optional, bool, True by default) – Whether the stream/file object shall be closed, this only work when using open_las in a with statement. An exception is raised if closefd is specified and the source is a filename
encoding_errors (str, default 'strict') – Only used in writing and appending mode. How encoding errors should be treated. Possible values and their explanation can be seen here: https://docs.python.org/3/library/codecs.html#error-handlers.
read_evlrs (bool, default True) –
Only applies to ‘r’ mode.
If True the evlrs will be read during the __init__ / file opening along with the LasHeader.
It is fine for most of the cases, but can be problematic when opening file from a data stream like AWS S3 as EVLRs are located at the end of the files, thus will require to pull the whole file.
Does nothing if the input file does not support EVLRs
decompression_selection (DecompressionSelection, default All) –
Only applies to ‘r’ mode and for files which suport selective decompression (version >= 1.4 and point format id >= 6), ignored otherwise.
Allows to select which fields should be decompressed or not, allowing to save time by not decompressing unused fields.
By default all fields are decompressed
versionadded: (..) – 2.4: The
read_evlrs
anddecompression_selection
parameters.
laspy.create¶
- laspy.create(*, point_format: Optional[Union[PointFormat, int]] = None, file_version: Optional[Union[Version, str]] = None)¶
Function to create a new empty las data object
Note
If you provide both point_format and file_version an exception will be raised if they are not compatible
>>> las = create_las(point_format=6,file_version="1.2") Traceback (most recent call last): ... laspy.errors.LaspyException: Point format 6 is not compatible with file version 1.2
If you provide only the point_format the file_version will automatically selected for you.
>>> las = create_las(point_format=0) >>> las.header.version == '1.2' True
>>> las = create_las(point_format=PointFormat(6)) >>> las.header.version == '1.4' True
- Parameters:
point_format – The point format you want the created file to have
file_version – The las version you want the created las to have
- Returns:
A new las data object
- Return type:
laspy.lasdatas.base.LasBase
laspy.convert¶
- laspy.convert(source_las, *, point_format_id=None, file_version=None)[source]¶
Converts a Las from one point format to another Automatically upgrades the file version if source file version is not compatible with the new point_format_id
convert to point format 0
>>> las = read_las('tests/data/simple.las') >>> las.header.version Version(major=1, minor=2) >>> las = convert(las, point_format_id=0) >>> las.header.point_format.id 0 >>> str(las.header.version) '1.2'
convert to point format 6, which need version >= 1.4 then convert back to point format 0, version is not downgraded
>>> las = read_las('tests/data/simple.las') >>> str(las.header.version) '1.2' >>> las = convert(las, point_format_id=6) >>> las.header.point_format.id 6 >>> str(las.header.version) '1.4' >>> las = convert(las, point_format_id=0) >>> str(las.header.version) '1.4'
an exception is raised if the requested point format is not compatible with the file version
>>> las = read_las('tests/data/simple.las') >>> convert(las, point_format_id=6, file_version='1.2') Traceback (most recent call last): ... laspy.errors.LaspyException: Point format 6 is not compatible with file version 1.2
- Parameters:
source_las (laspy.lasdatas.base.LasBase) – The source data to be converted
point_format_id (int, optional) – The new point format id (the default is None, which won’t change the source format id)
file_version (str, optional,) – The new file version. None by default which means that the file_version may be upgraded for compatibility with the new point_format. The file version will not be downgraded.
- Return type:
laspy.lasdatas.base.LasBase
Re-exported classes¶
Submodules¶
- laspy.lib module
- laspy.header module
- LasHeader
LasHeader
LasHeader.DEFAULT_VERSION
LasHeader.DEFAULT_POINT_FORMAT
LasHeader.file_source_id
LasHeader.uuid
LasHeader.system_identifier
LasHeader.generating_software
LasHeader.creation_date
LasHeader.point_count
LasHeader.scales
LasHeader.offsets
LasHeader.number_of_points_by_return
LasHeader.extra_header_bytes
LasHeader.extra_vlr_bytes
LasHeader.start_of_waveform_data_packet_record
LasHeader.start_of_first_evlr
LasHeader.number_of_evlrs
LasHeader.evlrs
LasHeader.point_format
LasHeader.version
LasHeader.x_scale
LasHeader.y_scale
LasHeader.z_scale
LasHeader.x_offset
LasHeader.y_offset
LasHeader.z_offset
LasHeader.x_max
LasHeader.y_max
LasHeader.z_max
LasHeader.x_min
LasHeader.y_min
LasHeader.z_min
LasHeader.vlrs
LasHeader.add_extra_dims()
LasHeader.add_extra_dim()
LasHeader.add_crs()
LasHeader.remove_extra_dim()
LasHeader.remove_extra_dims()
LasHeader.set_version_and_point_format()
LasHeader.grow()
LasHeader.parse_crs()
LasHeader.read_evlrs()
LasHeader.major_version
LasHeader.minor_version
- LasHeader
- laspy.lasreader module
- laspy.lasdata module
- laspy.copc module
- laspy.vlrs.vlrlist module
- laspy.vlrs.known module
IKnownVLR
BaseKnownVLR
ClassificationLookupVlr
LasZipVlr
ExtraBytesStruct
ExtraBytesStruct.NO_DATA_BIT_MASK
ExtraBytesStruct.MIN_BIT_MASK
ExtraBytesStruct.MAX_BIT_MASK
ExtraBytesStruct.SCALE_BIT_MASK
ExtraBytesStruct.OFFSET_BIT_MASK
ExtraBytesStruct.no_data
ExtraBytesStruct.min
ExtraBytesStruct.max
ExtraBytesStruct.offset
ExtraBytesStruct.scale
ExtraBytesStruct.format_name()
ExtraBytesStruct.dtype()
ExtraBytesStruct.num_elements()
ExtraBytesStruct.size()
ExtraBytesStruct.data_type
ExtraBytesStruct.description
ExtraBytesStruct.name
ExtraBytesStruct.options
ExtraBytesStruct.reserved
ExtraBytesStruct.unused
ExtraBytesVlr
WaveformPacketStruct
WaveformPacketVlr
GeoKeyEntryStruct
GeoKeysHeaderStructs
GeoKeyDirectoryVlr
GeoDoubleParamsVlr
GeoAsciiParamsVlr
WktMathTransformVlr
WktCoordinateSystemVlr
vlr_factory()
- laspy.vlrs.vlr
- laspy.point.record module
scale_dimension()
unscale_dimension()
DimensionNameValidity
PackedPointRecord
PackedPointRecord.point_size
PackedPointRecord.zeros()
PackedPointRecord.empty()
PackedPointRecord.from_point_record()
PackedPointRecord.from_buffer()
PackedPointRecord.copy_fields_from()
PackedPointRecord.copy()
PackedPointRecord.memoryview()
PackedPointRecord.resize()
PackedPointRecord.validate_dimension_name()
apply_new_scaling()
ScaleAwarePointRecord
- laspy.errors module
- laspy.compression module
- LazBackend
- DecompressionSelection
DecompressionSelection
DecompressionSelection.XY_RETURNS_CHANNEL
DecompressionSelection.Z
DecompressionSelection.CLASSIFICATION
DecompressionSelection.FLAGS
DecompressionSelection.INTENSITY
DecompressionSelection.SCAN_ANGLE
DecompressionSelection.USER_DATA
DecompressionSelection.POINT_SOURCE_ID
DecompressionSelection.GPS_TIME
DecompressionSelection.RGB
DecompressionSelection.NIR
DecompressionSelection.WAVEPACKET
DecompressionSelection.ALL_EXTRA_BYTES
DecompressionSelection.all()
DecompressionSelection.base()
DecompressionSelection.xy_returns_channel()
DecompressionSelection.to_lazrs()
DecompressionSelection.to_laszip()
DecompressionSelection.is_set()
DecompressionSelection.decompress_all_extra_bytes()
DecompressionSelection.skip_all_extra_bytes()
DecompressionSelection.is_set_all_extra_bytes()
DecompressionSelection.decompress_classification()
DecompressionSelection.skip_classification()
DecompressionSelection.is_set_classification()
DecompressionSelection.decompress_flags()
DecompressionSelection.skip_flags()
DecompressionSelection.is_set_flags()
DecompressionSelection.decompress_gps_time()
DecompressionSelection.skip_gps_time()
DecompressionSelection.is_set_gps_time()
DecompressionSelection.decompress_intensity()
DecompressionSelection.skip_intensity()
DecompressionSelection.is_set_intensity()
DecompressionSelection.decompress_nir()
DecompressionSelection.skip_nir()
DecompressionSelection.is_set_nir()
DecompressionSelection.decompress_point_source_id()
DecompressionSelection.skip_point_source_id()
DecompressionSelection.is_set_point_source_id()
DecompressionSelection.decompress_rgb()
DecompressionSelection.skip_rgb()
DecompressionSelection.is_set_rgb()
DecompressionSelection.decompress_scan_angle()
DecompressionSelection.skip_scan_angle()
DecompressionSelection.is_set_scan_angle()
DecompressionSelection.decompress_user_data()
DecompressionSelection.skip_user_data()
DecompressionSelection.is_set_user_data()
DecompressionSelection.decompress_wavepacket()
DecompressionSelection.skip_wavepacket()
DecompressionSelection.is_set_wavepacket()
DecompressionSelection.decompress_xy_returns_channel()
DecompressionSelection.skip_xy_returns_channel()
DecompressionSelection.is_set_xy_returns_channel()
DecompressionSelection.decompress_z()
DecompressionSelection.skip_z()
DecompressionSelection.is_set_z()
- laspy.point.format module
ExtraBytesParams
PointFormat
PointFormat.standard_dimensions
PointFormat.extra_dimensions
PointFormat.dimension_names
PointFormat.standard_dimension_names
PointFormat.extra_dimension_names
PointFormat.size
PointFormat.num_standard_bytes
PointFormat.num_extra_bytes
PointFormat.has_waveform_packet
PointFormat.dimension_by_name()
PointFormat.add_extra_dimension()
PointFormat.remove_extra_dimension()
PointFormat.dtype()
lost_dimensions()
- laspy.lasmmap module
- laspy.lasappender
- laspy.laswriter module