spdv3

SPD V3 format driver and support functions

pylidar.lidarformats.spdv3.HEADER_ARRAY_FIELDS = ('BANDWIDTHS', 'WAVELENGTHS')

header fields that are actually arrays

pylidar.lidarformats.spdv3.HEADER_FIELDS = {'CREATION_HOUR_OF': <type 'numpy.uint16'>, 'USER_META_DATA': <type 'str'>, 'SYSTEM_IDENTIFIER': <type 'str'>, 'Y_MAX': <type 'numpy.float64'>, 'PULSE_DENSITY': <type 'numpy.float32'>, 'FILE_TYPE': <type 'numpy.uint16'>, 'CAPTURE_SECOND_OF': <type 'numpy.uint16'>, 'BLOCK_SIZE_TRANSMITTED': <type 'numpy.uint16'>, 'VERSION_POINT': <type 'numpy.uint16'>, 'PULSE_ANGULAR_SPACING_ZENITH': <type 'numpy.float32'>, 'Z_MIN': <type 'numpy.float64'>, 'CAPTURE_YEAR_OF': <type 'numpy.uint16'>, 'ZENITH_MAX': <type 'numpy.float64'>, 'DEFINED_DISCRETE_PT': <type 'numpy.int16'>, 'X_MAX': <type 'numpy.float64'>, 'BLOCK_SIZE_PULSE': <type 'numpy.uint16'>, 'SENSOR_HEIGHT': <type 'numpy.float64'>, 'SCANLINE_MAX': <type 'numpy.float64'>, 'ZENITH_MIN': <type 'numpy.float64'>, 'BLOCK_SIZE_POINT': <type 'numpy.uint16'>, 'CREATION_DAY_OF': <type 'numpy.uint16'>, 'NUMBER_OF_POINTS': <type 'numpy.uint64'>, 'VERSION_PULSE': <type 'numpy.uint16'>, 'GENERATING_SOFTWARE': <type 'str'>, 'PULSE_FOOTPRINT': <type 'numpy.float32'>, 'SCANLINE_IDX_MAX': <type 'numpy.float64'>, 'BANDWIDTHS': <type 'numpy.float32'>, 'RANGE_MIN': <type 'numpy.float64'>, 'Z_MAX': <type 'numpy.float64'>, 'SENSOR_SCAN_RATE': <type 'numpy.float32'>, 'FIELD_OF_VIEW': <type 'numpy.float32'>, 'CAPTURE_MINUTE_OF': <type 'numpy.uint16'>, 'VERSION_MAJOR_SPD': <type 'numpy.uint16'>, 'CAPTURE_HOUR_OF': <type 'numpy.uint16'>, 'CREATION_MINUTE_OF': <type 'numpy.uint16'>, 'CAPTURE_DAY_OF': <type 'numpy.uint16'>, 'SCANLINE_IDX_MIN': <type 'numpy.float64'>, 'BLOCK_SIZE_RECEIVED': <type 'numpy.uint16'>, 'SENSOR_TEMPORAL_BIN_SPACING': <type 'numpy.float64'>, 'NUM_OF_WAVELENGTHS': <type 'numpy.uint16'>, 'Y_MIN': <type 'numpy.float64'>, 'SENSOR_SPEED': <type 'numpy.float32'>, 'CAPTURE_MONTH_OF': <type 'numpy.uint16'>, 'DEFINED_RGB': <type 'numpy.int16'>, 'RANGE_MAX': <type 'numpy.float64'>, 'PULSE_ENERGY': <type 'numpy.float32'>, 'CREATION_YEAR_OF': <type 'numpy.uint16'>, 'DEFINED_RECEIVE_WAVEFORM': <type 'numpy.int16'>, 'AZIMUTH_MAX': <type 'numpy.float64'>, 'DEFINED_HEIGHT': <type 'numpy.int16'>, 'SENSOR_PULSE_REPETITION_FREQ': <type 'numpy.float32'>, 'PULSE_CROSS_TRACK_SPACING': <type 'numpy.float32'>, 'SENSOR_BEAM_DIVERGENCE': <type 'numpy.float32'>, 'VERSION_MINOR_SPD': <type 'numpy.uint16'>, 'RETURN_NUMBERS_SYN_GEN': <type 'numpy.int16'>, 'SENSOR_MAX_SCAN_ANGLE': <type 'numpy.float32'>, 'AZIMUTH_MIN': <type 'numpy.float64'>, 'CREATION_SECOND_OF': <type 'numpy.uint16'>, 'WAVEFORM_BIT_RES': <type 'numpy.uint16'>, 'PULSE_INDEX_METHOD': <type 'numpy.uint16'>, 'INDEX_TYPE': <type 'numpy.uint16'>, 'WAVELENGTHS': <type 'numpy.float32'>, 'PULSE_ALONG_TRACK_SPACING': <type 'numpy.float32'>, 'FILE_SIGNATURE': <type 'str'>, 'CREATION_MONTH_OF': <type 'numpy.uint16'>, 'NUMBER_OF_PULSES': <type 'numpy.uint64'>, 'DEFINED_DECOMPOSED_PT': <type 'numpy.int16'>, 'DEFINED_TRANS_WAVEFORM': <type 'numpy.int16'>, 'BIN_SIZE': <type 'numpy.float32'>, 'PULSE_ANGULAR_SPACING_AZIMUTH': <type 'numpy.float32'>, 'SCANLINE_MIN': <type 'numpy.float64'>, 'DEFINED_ORIGIN': <type 'numpy.int16'>, 'SPATIAL_REFERENCE': <type 'str'>, 'X_MIN': <type 'numpy.float64'>, 'POINT_DENSITY': <type 'numpy.float32'>, 'NUMBER_BINS_X': <type 'numpy.uint32'>, 'NUMBER_BINS_Y': <type 'numpy.uint32'>, 'SENSOR_APERTURE_SIZE': <type 'numpy.float32'>}

Header fields and their types

pylidar.lidarformats.spdv3.HEADER_TRANSLATION_DICT = {1: 'NUMBER_OF_POINTS'}

Translation of header field names

pylidar.lidarformats.spdv3.POINTS_HEADER_UPDATE_DICT = {'Y': ('Y_MIN', 'Y_MAX'), 'X': ('X_MIN', 'X_MAX'), 'RANGE': ('RANGE_MIN', 'RANGE_MAX'), 'Z': ('Z_MIN', 'Z_MAX')}

for updating the header

pylidar.lidarformats.spdv3.POINT_DTYPE = dtype([('RETURN_ID', 'u1'), ('GPS_TIME', '<f8'), ('X', '<f8'), ('Y', '<f8'), ('Z', '<f4'), ('HEIGHT', '<f4'), ('RANGE', '<f4'), ('AMPLITUDE_RETURN', '<f4'), ('WIDTH_RETURN', '<f4'), ('RED', '<u2'), ('GREEN', '<u2'), ('BLUE', '<u2'), ('CLASSIFICATION', 'u1'), ('USER_FIELD', '<u4'), ('IGNORE', 'u1'), ('WAVE_PACKET_DESC_IDX', '<i2'), ('WAVEFORM_OFFSET', '<u4')])

so we can check the user has passed in expected array type

pylidar.lidarformats.spdv3.PULSES_HEADER_UPDATE_DICT = {'SCANLINE': ('SCANLINE_MIN', 'SCANLINE_MAX'), 'SCANLINE_IDX': ('SCANLINE_IDX_MIN', 'SCANLINE_IDX_MAX'), 'ZENITH': ('ZENITH_MIN', 'ZENITH_MAX'), 'AZIMUTH': ('AZIMUTH_MIN', 'AZIMUTH_MAX')}

for updating the header

pylidar.lidarformats.spdv3.PULSE_DTYPE = dtype([('GPS_TIME', '<u8'), ('PULSE_ID', '<u8'), ('X_ORIGIN', '<f8'), ('Y_ORIGIN', '<f8'), ('Z_ORIGIN', '<f4'), ('H_ORIGIN', '<f4'), ('X_IDX', '<f8'), ('Y_IDX', '<f8'), ('AZIMUTH', '<f4'), ('ZENITH', '<f4'), ('NUMBER_OF_RETURNS', 'u1'), ('NUMBER_OF_WAVEFORM_TRANSMITTED_BINS', '<u2'), ('NUMBER_OF_WAVEFORM_RECEIVED_BINS', '<u2'), ('RANGE_TO_WAVEFORM_START', '<f4'), ('AMPLITUDE_PULSE', '<f4'), ('WIDTH_PULSE', '<f4'), ('USER_FIELD', '<u4'), ('SOURCE_ID', '<u2'), ('SCANLINE', '<u4'), ('SCANLINE_IDX', '<u2'), ('RECEIVE_WAVE_NOISE_THRES', '<f4'), ('TRANS_WAVE_NOISE_THRES', '<f4'), ('WAVELENGTH', '<f4'), ('RECEIVE_WAVE_GAIN', '<f4'), ('RECEIVE_WAVE_OFFSET', '<f4'), ('TRANS_WAVE_GAIN', '<f4'), ('TRANS_WAVE_OFFSET', '<f4'), ('PTS_START_IDX', '<u8'), ('TRANSMITTED_START_IDX', '<u8'), ('RECEIVED_START_IDX', '<u8')])

so we can check the user has passed in expected array type

class pylidar.lidarformats.spdv3.SPDV3File(fname, mode, controls, userClass)[source]

Class to support reading and writing of SPD Version 3.x files.

Uses h5py to handle access to the underlying HDF5 file.

close()[source]

Write out the spatial index, header and close file handle.

static convertHeaderToDictionary(header)[source]

Static method to convert the header returned by h5py into a normal dictionary

static getDriverName()[source]

Name of this driver

getHeader()[source]

Return our cached dictionary

static getHeaderTranslationDict()[source]

Return dictionary with non-standard header names

getHeaderValue(name)[source]

Just extract the one value and return it

getNativeDataType(colName, arrayType)[source]

Return the native dtype (numpy.int16 etc)that a column is stored as internally. Provided so scaling can be adjusted when translating between formats.

arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants

getPixelGrid()[source]

Return the pixel grid of this spatial index.

getTotalNumberPulses()[source]

Return the total number of pulses

static getTranslationDict(arrayType)[source]

Translation dictionary between formats

hasSpatialIndex()[source]

Return True if we have a spatial index.

preparePointsForWriting(points, pulses)[source]

Called from writeData(). Massages what the user has passed into something we can write back to the file.

preparePulsesForWriting(pulses)[source]

Called from writeData(). Massages what the user has passed into something we can write back to the file.

prepareReceivedForWriting(received, waveformInfo)[source]

Called from writeData(). Massages what the user has passed into something we can write back to the file.

prepareTransmittedForWriting(transmitted, waveformInfo)[source]

Called from writeData(). Massages what the user has passed into something we can write back to the file.

readPointsByPulse(colNames=None)[source]

Return a 2d masked structured array of point that matches the pulses.

readPointsForExtent(colNames=None)[source]

Read out the points for the given extent as a 1d structured array.

readPointsForExtentByBins(extent=None, colNames=None, indexByPulse=False, returnPulseIndex=False)[source]

Return the points as a 3d structured masked array.

Note that because the spatial index on a SPDV3 file is on pulses this may miss points that are attached to pulses outside the current extent. If this is a problem then select an overlap large enough.

Pass indexByPulse=True to bin the points by the locations of the pulses
(using X_IDX and Y_IDX rather than the locations 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]

Read all the points for the specified range of pulses

readPulsesForExtent(colNames=None)[source]

Return the pulses for the given extent as a 1d structured array

readPulsesForExtentByBins(extent=None, colNames=None)[source]

Return the pulses as a 3d structured masked array.

readPulsesForRange(colNames=None)[source]

Read the specified range of pulses

readReceived()[source]

Return the 3d masked integer array of received for each of the current pulses. SPDV3 only has 1 transmitted per pulse so the second axis is empty. First axis is waveform bin and last is pulse.

readTransmitted()[source]

Return the 3d masked integer array of transmitted for each of the current pulses. SPDV3 only has 1 transmitted per pulse so the second axis is empty. First axis is waveform bin and last is pulse.

readWaveformInfo()[source]

Return 2d masked array of information about the waveforms.

setExtent(extent)[source]

Set the extent to use for the ForExtent() functions.

setHeader(newHeaderDict)[source]

Update our cached dictionary

setHeaderValue(name, value)[source]

Just update one value in the header

setPixelGrid(pixGrid)[source]

Set the pixel grid on creation or update

setPulseRange(pulseRange)[source]

Set the range of pulses to read

updateHeaderFromData(points, pulses)[source]

Given some data, updates the _MIN, _MAX etc

writeData(pulses=None, points=None, transmitted=None, received=None, waveformInfo=None)[source]

Write all the updated data. Pass None for data that do not need to be updated. It is assumed that each parameter has been read by the reading functions

class pylidar.lidarformats.spdv3.SPDV3FileInfo(fname)[source]

Class that gets information about a SPDV3 file and makes it available as fields.

static getDriverName()[source]

Name of this driver

static getHeaderTranslationDict()[source]

Return dictionary with non-standard header names

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_ALLCLASSES = 100

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_ALLCLASSES_TOP = 101

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_BRANCH = 11

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_BUILDING = 7

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_CREATED = 2

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_FOLIAGE = 10

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_GROUND = 3

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_HIGHVEGE = 6

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_KEYGRDPTS = 105

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_LOWVEGE = 4

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_MEDVEGE = 5

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_NOTGROUND = 104

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_TRUNK = 9

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_UNCLASSIFIED = 1

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_UNDEFINED = 0

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_VEGE = 103

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_VEGETOP = 102

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_WALL = 12

classification codes

pylidar.lidarformats.spdv3.SPDV3_CLASSIFICATION_WATER = 8

classification codes

pylidar.lidarformats.spdv3.SPDV3_INDEX_CARTESIAN = 1

types of indexing in the file

pylidar.lidarformats.spdv3.SPDV3_INDEX_CYLINDRICAL = 3

types of indexing in the file

pylidar.lidarformats.spdv3.SPDV3_INDEX_POLAR = 4

types of indexing in the file

pylidar.lidarformats.spdv3.SPDV3_INDEX_SCAN = 5

types of indexing in the file

pylidar.lidarformats.spdv3.SPDV3_INDEX_SPHERICAL = 2

types of indexing in the file

pylidar.lidarformats.spdv3.SPDV3_SI_COUNT_DTYPE

types for the spatial index

alias of uint32

pylidar.lidarformats.spdv3.SPDV3_SI_INDEX_DTYPE

types for the spatial index

alias of uint64