las¶
Driver for .las files. Uses lastools (https://github.com/LAStools/LAStools).
Read Driver Options¶
These are contained in the READSUPPORTEDOPTIONS module level variable.
Name | Use |
---|---|
BUILD_PULSES | a boolean. If set to true (the default) pylidar attempts to build pulses assuming that data is in time sequential order. If false, a ‘fake’ pulse is created for each point. |
BIN_SIZE | A number. For files with a spatial index present this is the bin size that the File be presented at. Las indexes can use any arbitary bin size it seems, but works to specific ones which can be set with this option for this file. An error will be raised if a spatial read is attempted and this hasn’t been set. |
PULSE_INDEX | Either FIRST_RETURN or LAST_RETURN Dictates which point will be used to set the X_IDX and Y_IDX pulse fields |
Write Driver Options¶
These are contained in the WRITESUPPORTEDOPTIONS module level variable.
Name | Use |
---|---|
FORMAT_VERSION | LAS point format. Defaults to 1. Not sure what it means. |
RECORD_LENGTH | LAS record length. Defaults to 28. Not sure what it means. |
WAVEFORM_DESCR | Data returned from getWavePacketDescriptions() which does an initial run through the data to get the unique waveform info for writing to the LAS header. No output waveforms are written if this is not provided. |
Note that for writing, the extension currently controls the format witten:
Extension | Format |
.las | LAS |
.laz | LAZ (compressed las) |
.bin | terrasolid |
.qi | QFIT |
.wrl | VRML |
other | ASCII |
-
pylidar.lidarformats.las.
DEFAULT_HEADER
= {'FILE_CREATION_DAY': 193, 'FILE_CREATION_YEAR': 2022, 'GENERATING_SOFTWARE': 'PyLidar 0.4.4'}¶ for new files
-
pylidar.lidarformats.las.
FIRST_RETURN
= None¶ for indexing pulses
-
pylidar.lidarformats.las.
HEADER_TRANSLATION_DICT
= {1: 'NUMBER_OF_POINT_RECORDS'}¶ Non standard header names
-
pylidar.lidarformats.las.
LAST_RETURN
= None¶ for indexing pulses
-
pylidar.lidarformats.las.
LAS_SIMPLEGRID_COUNT_DTYPE
¶ alias of
numpy.uint32
-
pylidar.lidarformats.las.
LAS_SIMPLEGRID_INDEX_DTYPE
¶ alias of
numpy.uint64
-
pylidar.lidarformats.las.
LAS_WAVEFORM_TABLE_FIELDS
= []¶ for building waveforms - need to build unique table of these
-
class
pylidar.lidarformats.las.
LasFile
(fname, mode, controls, userClass)[source]¶ Reader/Writer for .las files.
-
getNativeDataType
(colName, arrayType)[source]¶ Return the native dtype (numpy.int16 etc)that a column is stored as internally after scaling is applied. Provided so scaling can be adjusted when translating between formats.
arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants
-
getScaling
(colName, arrayType)[source]¶ Returns the scaling (gain, offset) for the given column name reads from our cache since only written to file on close
Raises generic.LiDARArrayColumnError if no scaling (yet) set for this column.
-
getScalingColumns
(arrayType)[source]¶ Return the list of columns that need scaling. Only valid on write
-
getTotalNumberPulses
()[source]¶ If BUILD_PULSES == False then the number of pulses will equal the number of points and we can return that. Otherwise we have no idea how many so we raise an exception to flag that.
-
readPointsByPulse
(colNames=None)[source]¶ Read a 2d structured masked array containing the points for each pulse.
-
readPointsForExtent
(colNames=None)[source]¶ Read all the points within the given extent as 1d structured array. The names of the fields in this array will be defined by the driver.
colNames can be a name or list of column names to return. By default all columns are returned.
-
readPointsForExtentByBins
(extent=None, colNames=None, indexByPulse=False, returnPulseIndex=False)[source]¶ Read all the points within the given extent as a 3d structured masked array to match the block/bins being used.
The extent/binning for the read data can be overriden by passing in a Extent instance.
colNames can be a name or list of column names to return. By default all columns are returned.
- Pass indexByPulse=True to bin the points by the locations of the pulses
- instead of the points.
- Pass returnPulseIndex=True to also return a masked 3d array of
- the indices into the 1d pulse array (as returned by readPulsesForExtent())
-
readPointsForRange
(colNames=None)[source]¶ Reads the points for the current range. Returns a 1d array.
Returns an empty array if range is outside of the current file.
colNames can be a list of column names to return. By default all columns are returned.
-
readPulsesForExtent
(colNames=None)[source]¶ Read all the pulses within the given extent as 1d structured array. The names of the fields in this array will be defined by the driver.
colNames can be a name or list of column names to return. By default all columns are returned.
-
readPulsesForExtentByBins
(extent=None, colNames=None)[source]¶ Read all the pulses within the given extent as a 3d structured masked array to match the block/bins being used.
The extent/binning for the read data can be overriden by passing in a Extent instance.
colNames can be a name or list of column names to return. By default all columns are returned.
-
readPulsesForRange
(colNames=None)[source]¶ Reads the pulses for the current range. Returns a 1d array.
Returns an empty array if range is outside of the current file.
colNames can be a list of column names to return. By default all columns are returned.
-
setNativeDataType
(colName, arrayType, dtype)[source]¶ Set the native dtype (numpy.int16 etc)that a column is stored as internally after scaling (if any) is applied.
arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants
generic.LiDARArrayColumnError is raised if this cannot be set for the format.
The default behaviour is to create new columns in the correct type for the format, or if they are optional, in the same type as the input array.
-
setPixelGrid
(pixGrid)[source]¶ Set the PixelGridDefn for the reading or writing. We don’t need to do much here apart from record the EPSG since LAS doesn’t use a grid.
-
-
class
pylidar.lidarformats.las.
LasFileInfo
(fname)[source]¶ Class that gets information about a .las file and makes it available as fields.
-
pylidar.lidarformats.las.
READSUPPORTEDOPTIONS
= None¶ driver options
-
pylidar.lidarformats.las.
WRITESUPPORTEDOPTIONS
= None¶ driver options
-
pylidar.lidarformats.las.
gatherWavePackets
(data, otherArgs)[source]¶ Called from lidarprocessor, is the function that does the identification of unique waveform length and gain and offset.
-
pylidar.lidarformats.las.
getWavePacketDescriptions
(fname)[source]¶ When writing a LAS file, it is necessary to write information to a table in the header that really belongs to the waveforms. This function reads the waveform info from the input file (in any format) and gathers the unique information from it so it can be passed to as the WAVEFORM_DESCR LAS driver option.
Note: LAS only supports received waveforms.