userclasses

Classes that are passed to the user’s function

class pylidar.userclasses.DataContainer(controls)[source]

This is a container object used for passing as the first parameter to the user function. It contains a UserInfo object (called ‘info’) plus instances of LidarData and ImageData (see below). These objects will be named in the same way that the LidarFile and ImageFile were in the DataFiles object that was passed to doProcessing().

class pylidar.userclasses.ImageData(mode, driver)[source]

Class that allows reading and writing to/from an image file. Passed to the user function from a field on the DataContainer object.

Calls though to the driver instance it was constructed with to do the actual work.

flush()[source]

Now actually do the write

getData()[source]

Returns the data for the current extent as a 3d numpy array in the same data type as the image file.

setData(data)[source]

Sets the image data for the current extent. The data type of the passed in numpy array will be the data type for the newly created file.

class pylidar.userclasses.LidarData(mode, driver)[source]

Class that allows reading and writing to/from a LiDAR file. Passed to the user function from a field on the DataContainer object.

Calls though to the driver instance it was constructed with to do the actual work.

static convertToStructIfNeeded(data, colName, oldData=None)[source]

Converts data to a structured array if it is not. If conversion is required it uses colName and data type of data. Raises exception if conversion not possible or does not make sense.

if oldData is not None and data is non-structured, then the new data is appended onto oldData and returned. If data is structured, and error is raised.

flush()[source]

writes data to file set via the set*() functions

getHeader()[source]

Returns the header as a dictionary of header key/value pairs.

getHeaderTranslationDict()[source]

Return a dictionary keyed on HEADER_* values (above) that can be used to translate dictionary field names between the formats

getHeaderValue(name)[source]

Gets a particular header value with the given name

getNativeDataType(colName, arrayType)[source]

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

arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants

generic.LiDARArrayColumnError is raised if information cannot be found.

getNullValue(colName, arrayType, scaled=True)[source]

Get the ‘null’ value for the given column.

arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants

By default the returned value is scaled, change this with the ‘scaled’ parameter.

Raises generic.LiDARArrayColumnError if information cannot be found for the column.

getPoints(colNames=None)[source]

Returns the points for the extent/range of the current block as a structured array. The fields on this array are defined by the driver being used.

colNames can be a name or list of column names to return. By default all columns are returned.

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

Returns the points for the extent of the current block as a 3 dimensional structured masked array. Only valid for spatial processing. The fields on this array are defined by the driver being used.

First axis is the points in each bin, second axis is the rows, third is the columns.

Some bins have more points that others so the mask is set to True when data not valid.

The extent/binning for the read data can be overriden by passing in a basedriver.Extent instance.

colNames can be a name or list of column names to return. By default all columns are returned.

Set indexByPulse to True to bin points by the pulse index location rather than point location.

Set returnPulseIndex to True to also return a 3 dimensional masked array containing the indexes into the 1d array returned by getPulses().

getPointsByPulse(colNames=None)[source]

Returns the points as a 2d structured masked array. The first axis is the same length as the pulse array but the second axis contains the points for each pulse. The mask will be set to True where no valid data since some pulses will have more points than others.

colNames can be a name or list of column names to return. By default all columns are returned.

getPulses(colNames=None, pulseIndex=None)[source]

Returns the pulses for the extent/range of the current block as a structured array. The fields on this array are defined by the driver being used.

colNames can be a name or list of column names to return. By default all columns are returned.

pulseIndex is an optional masked 3d array of indices to remap the 1d pulse array to a 3D point by bin array. pulseIndex is returned from getPointsByBins with returnPulseIndex=True.

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

Returns the pulses for the extent of the current block as a 3 dimensional structured masked array. Only valid for spatial processing. The fields on this array are defined by the driver being used.

First axis is the pulses in each bin, second axis is the rows, third is the columns.

Some bins have more pulses that others so the mask is set to True when data not valid.

The extent/binning for the read data can be overriden by passing in a basedriver.Extent instance.

colNames can be a name or list of column names to return. By default all columns are returned.

getReceived()[source]

Returns a masked 3d radiance array. The first axis is the waveform bins, the second axis will be the waveform number and the third axis axis will be the same length as the pulses.

Because some pulses will have a longer waveform than others a masked array is returned.

getScaling(colName, arrayType)[source]

Returns the scaling (gain, offset) for the given column name

arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants

getScalingColumns(arrayType)[source]

Return a list of column names that require scaling to be set on write.

arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants

getTransmitted()[source]

Returns a masked 3d radiance array. The first axis is the waveform bins, the second axis will be the waveform number and the third axis axis will be the same length as the pulses.

Because some pulses will have a longer waveform than others a masked array is returned.

getWaveformInfo()[source]

Returns a 2d masked structured array with information about the waveforms. First axis will be the waveform number, second will be same length as the pulses

rebinPtsByHeight(pointsByBin, bins, heightArray=None, heightField='Z')[source]

pointsByBin 3d ragged (masked) structured array of points. (nrows, ncols, npts) bins Height bins into which to stratify points

Set heightArray to a masked array of values used to vertically stratify the points. This allows columns not in pointsByBin to be used.

Set heightField to specify which pointsByBin column name to use for height values. Only used if heightArray is None.

Return:
4d re-binned copy of pointsByBin
setHeader(headerDict)[source]

Sets header values as a dictionary of header key/value pairs.

setHeaderValue(name, value)[source]

Sets a particular header value with the given name

setHeaderValues(**kwargs)[source]

Overloaded version to support key word args instead

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 information cannot be found.

setNullValue(colName, arrayType, value, scaled=True)[source]

Set the ‘null’ value for the given column.

arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants

By default the value is treated as the scaled value, but this can be changed with the ‘scaled’ parameter.

generic.LiDARArrayColumnError is raised if this cannot be set for the column.

setPoints(points, colName=None)[source]

Write the points to a file. If passed a structured array, the same field names are expected as those read with the same driver.

If the array is non-structured (ie you passed a colNames as a string to getPoints()) you need to pass the same string as the colName parameter.

Pass either a 1d array (like that read from getPoints()) or a 3d masked array (like that read from getPointsByBins()).

setPulses(pulses, colName=None)[source]

Write the pulses to a file. If passed a structured array, the same field names are expected as those read with the same driver.

If the array is non-structured (ie you passed a colNames as a string to getPulses()) you need to pass the same string as the colName parameter.

Pass either a 1d array (like that read from getPulses()) or a 3d masked array (like that read from getPulsesByBins()).

setReceived(received)[source]

Set the received waveform for each pulse as a masked 3d integer array.

setScaling(colName, arrayType, gain, offset)[source]

Set the scaling for the given column name

arrayType is one of the lidarprocessor.ARRAY_TYPE_* constants

setTransmitted(transmitted)[source]

Set the transmitted waveform for each pulse as a masked 3d integer array.

setWaveformInfo(info, colName=None)[source]

Set the waveform info as a masked 2d array.

If passed a structured array, the same field names are expected as those read with the same driver.

If the array is non-structured (ie you passed a colNames as a string to getWaveformInfo()) you need to pass the same string as the colName parameter.

translateFieldNames(otherLidarData, array, arrayType)[source]

Translates the field names in an array from another format (specified by passing the other data object) for use in writing to the format for this driver. The array is passed in and updated directly (no copy made). The array is returned.

arrayType is one of the ARRAY_TYPE_* values defined in lidarprocessor.py.

class pylidar.userclasses.UserInfo(controls)[source]

The ‘DataContainer’ object (below) contains an ‘info’ field which is an instance of this class. The user function can use these methods to obtain information on the current processing state and region.

Equivalent to the RIOS ‘info’ object.

getBlockCoordArrays()[source]

Return a tuple of the world coordinates for every pixel in the current block. Each array has the same shape as the current block. Return value is a tuple:

(xBlock, yBlock)

where the values in xBlock are the X coordinates of the centre of each pixel, and similarly for yBlock.

The coordinates returned are for the pixel centres. This is slightly inconsistent with usual GDAL usage, but more likely to be what one wants.

getControls()[source]

Return the instance of the controls object used for processing

getExtent()[source]

Get the extent of the current block being procesed. This is only valid when spatial processing is enabled. Otherwise use getRange()

This is an instance of .basedriver.Extent.

getPixGrid()[source]

Return the current pixgrid. This defines the current total processing extent, resolution and projection.

Is an instance of rios.pixelgrid.PixelGridDefn.

getRange()[source]

Get the range of pulses being processed. This is only vaid when spatial processing is disabled. When doing spatial processing, use getExtent().

isFirstBlock()[source]

Returns True if this is the first block to be processed

isLastBlock()[source]

Returns True if this is the last block to be processed

setExtent(extent)[source]

For internal use. Used by the processor to set the current state.

setPixGrid(pixGrid)[source]

For internal use. Used by the processor to set the current state.

setRange(range)[source]

For internal use. Used by the processor to set the current state.