Translation

Module for doing translation between lidar formats

Command Line

Entry points for running the command line utils

Common functions

Common data and functions for translation

pylidar.toolbox.translate.translatecommon.DEFAULT_DTYPE_STR = 'DFLT'

Code that means: use the default type

pylidar.toolbox.translate.translatecommon.DEFAULT_SCALING = {0: {'AMPLITUDE_RETURN': [1.0, 0.0, <type 'numpy.uint16'>], 'HEIGHT': [100.0, -100.0, <type 'numpy.uint16'>], 'INTENSITY': [1.0, 0.0, <type 'numpy.uint16'>], 'RANGE': [100.0, 0.0, <type 'numpy.uint32'>], 'RHO_APP': [10000.0, 0.0, <type 'numpy.uint32'>], 'WIDTH_RETURN': [1.0, 0.0, <type 'numpy.uint16'>], 'X': [100.0, 0.0, <type 'numpy.uint32'>], 'Y': [100.0, 0.0, <type 'numpy.uint32'>], 'Z': [100.0, -100.0, <type 'numpy.uint32'>]}, 1: {'AMPLITUDE_PULSE': [100.0, 0.0, <type 'numpy.uint16'>], 'AZIMUTH': [100.0, 0.0, <type 'numpy.uint32'>], 'H_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>], 'WIDTH_PULSE': [100.0, 0.0, <type 'numpy.uint16'>], 'X_IDX': [100.0, 0.0, <type 'numpy.uint32'>], 'X_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>], 'Y_IDX': [100.0, 0.0, <type 'numpy.uint32'>], 'Y_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>], 'ZENITH': [100.0, 0.0, <type 'numpy.uint32'>], 'Z_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>]}, 2: {'RANGE_TO_WAVEFORM_START': [100.0, 0.0, <type 'numpy.uint32'>]}}

all the default scalings as a dictionary

pylidar.toolbox.translate.translatecommon.POINT_DEFAULT_SCALING = {'AMPLITUDE_RETURN': [1.0, 0.0, <type 'numpy.uint16'>], 'HEIGHT': [100.0, -100.0, <type 'numpy.uint16'>], 'INTENSITY': [1.0, 0.0, <type 'numpy.uint16'>], 'RANGE': [100.0, 0.0, <type 'numpy.uint32'>], 'RHO_APP': [10000.0, 0.0, <type 'numpy.uint32'>], 'WIDTH_RETURN': [1.0, 0.0, <type 'numpy.uint16'>], 'X': [100.0, 0.0, <type 'numpy.uint32'>], 'Y': [100.0, 0.0, <type 'numpy.uint32'>], 'Z': [100.0, -100.0, <type 'numpy.uint32'>]}

default scaling for points

pylidar.toolbox.translate.translatecommon.PULSE_DEFAULT_SCALING = {'AMPLITUDE_PULSE': [100.0, 0.0, <type 'numpy.uint16'>], 'AZIMUTH': [100.0, 0.0, <type 'numpy.uint32'>], 'H_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>], 'WIDTH_PULSE': [100.0, 0.0, <type 'numpy.uint16'>], 'X_IDX': [100.0, 0.0, <type 'numpy.uint32'>], 'X_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>], 'Y_IDX': [100.0, 0.0, <type 'numpy.uint32'>], 'Y_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>], 'ZENITH': [100.0, 0.0, <type 'numpy.uint32'>], 'Z_ORIGIN': [100.0, 0.0, <type 'numpy.uint32'>]}

Default scaling for pulses

pylidar.toolbox.translate.translatecommon.STRING_TO_DTYPE = {'FLOAT32': <type 'numpy.float32'>, 'FLOAT64': <type 'numpy.float64'>, 'INT16': <type 'numpy.int16'>, 'INT32': <type 'numpy.int32'>, 'INT64': <type 'numpy.int64'>, 'INT8': <type 'numpy.int8'>, 'UINT16': <type 'numpy.uint16'>, 'UINT32': <type 'numpy.uint32'>, 'UINT64': <type 'numpy.uint64'>, 'UINT8': <type 'numpy.uint8'>}

String to numpy dtype dictionary

pylidar.toolbox.translate.translatecommon.WAVEFORM_DEFAULT_SCALING = {'RANGE_TO_WAVEFORM_START': [100.0, 0.0, <type 'numpy.uint32'>]}

default scaling for waveforms

pylidar.toolbox.translate.translatecommon.addConstCols(constCols, points, pulses, waveforms=None)[source]

Add constant columns to points, pulses or waveforms

constCols is a list of tupes with (type, varname, dtype, value)

pylidar.toolbox.translate.translatecommon.checkRange(expectRange, points, pulses, waveforms=None)[source]

Checks the expected range against the data that has been passed. Raises an exception if data is outside of range

  • expectRange is a list of tuples with (type, varname, min, max).
  • points, pulses and waveforms are the arrays to check
pylidar.toolbox.translate.translatecommon.overRideDefaultScalings(scaling)[source]

Any scalings given on the commandline should over-ride the default behaviours. if scalings is not None then it is assumed to be a list of tuples with (type, varname, type, gain, offset).

Returns a dictionary keyed on lidarprocessor.ARRAY_TYPE_PULSES, lidarprocessor.ARRAY_TYPE_POINTS, or lidarprocessor.ARRAY_TYPE_WAVEFORMS. Each value in this dictionary is in turn a dictionary keyed on the column name in which each value is a tuple with gain, offset and dtype.

pylidar.toolbox.translate.translatecommon.setOutputNull(nullVals, output)[source]

Set the null values.

nullVals should be a list of (type, varname, value) tuples

Designed to be called from inside a lidarprocessor function so output should be an instance of pylidar.userclasses.LidarData.

pylidar.toolbox.translate.translatecommon.setOutputScaling(scalingDict, output)[source]

Set the scaling on the output SPD V4 file.

Designed to be called from inside a lidarprocessor function so output should be an instance of pylidar.userclasses.LidarData.

scalingDict should be what was returned by overRideDefaultScalings().

LAS to SPDV4

Handles conversion between LAS and SPDV4 formats

pylidar.toolbox.translate.las2spdv4.transFunc(data, otherArgs)[source]

Called from lidarprocessor. Does the actual conversion to SPD V4

pylidar.toolbox.translate.las2spdv4.translate(info, infile, outfile, expectRange=None, spatial=None, extent=None, scaling=None, epsg=None, binSize=None, buildPulses=False, pulseIndex=None, nullVals=None, constCols=None, useLASScaling=False)[source]

Main function which does the work.

  • Info is a fileinfo object for the input file.
  • infile and outfile are paths to the input and output files respectively.
  • expectRange is a list of tuples with (type, varname, min, max).
  • spatial is True or False - dictates whether we are processing spatially or not.
    If True then spatial index will be created on the output file on the fly.
  • extent is a tuple of values specifying the extent to work with.
    xmin ymin xmax ymax
  • scaling is a list of tuples with (type, varname, dtype, gain, offset).
  • if epsg is not None should be a EPSG number to use as the coord system
  • binSize is the used by the LAS spatial index
  • buildPulses dictates whether to attempt to build the pulse structure
  • pulseIndex should be ‘FIRST_RETURN’ or ‘LAST_RETURN’ and determines how the
    pulses are indexed.
  • nullVals is a list of tuples with (type, varname, value)
  • constCols is a list of tupes with (type, varname, dtype, value)
  • if useLASScaling is True, then the scaling used in the LAS file
    is used for columns. Overrides anything given in ‘scaling’
pylidar.toolbox.translate.las2spdv4.updateScalingWithLASValues(scalingDict, input, pointsArray)[source]

Updates scalingDict with scalings from input (a LAS file). pointsArray is needed so we know what fields exist in the input.

SPDV3 to SPDV4

Handles conversion between SPDV3 and SPDV4 formats

pylidar.toolbox.translate.spdv32spdv4.transFunc(data, otherArgs)[source]

Called from lidarprocessor. Does the actual conversion to SPD V4

pylidar.toolbox.translate.spdv32spdv4.translate(info, infile, outfile, expectRange=None, spatial=False, extent=None, scaling=None, nullVals=None, constCols=None)[source]

Main function which does the work.

  • Info is a fileinfo object for the input file.
  • infile and outfile are paths to the input and output files respectively.
  • expectRange is a list of tuples with (type, varname, min, max).
  • spatial is True or False - dictates whether we are processing spatially or not.
    If True then spatial index will be created on the output file on the fly.
  • extent is a tuple of values specifying the extent to work with.
    xmin ymin xmax ymax
  • scaling is a list of tuples with (type, varname, gain, offset).
  • nullVals is a list of tuples with (type, varname, value)
  • constCols is a list of tupes with (type, varname, dtype, value)

Riegl to SPDV4

ASCII to SPDV4

Handles conversion between ASCII and SPDV4 formats

pylidar.toolbox.translate.ascii2spdv4.transFunc(data, otherArgs)[source]

Called from lidarprocessor. Does the actual conversion to SPD V4

pylidar.toolbox.translate.ascii2spdv4.translate(info, infile, outfile, colTypes, pulseCols=None, expectRange=None, scaling=None, classificationTranslation=None, nullVals=None, constCols=None)[source]

Main function which does the work.

  • Info is a fileinfo object for the input file.
  • infile and outfile are paths to the input and output files respectively.
  • expectRange is a list of tuples with (type, varname, min, max).
  • scaling is a list of tuples with (type, varname, gain, offset).
  • colTypes is a list of name and data type tuples for every column
  • pulseCols is a list of strings defining the pulse columns
  • classificationTranslation is a list of tuples specifying how to translate
    between the codes within the files and the lidarprocessor.CLASSIFICATION_* ones. First element of tuple is file number, second the lidarprocessor code.
  • nullVals is a list of tuples with (type, varname, value)
  • constCols is a list of tupes with (type, varname, dtype, value)

SPDV4 to LAS

Handles conversion between SPDV4 and LAS formats

pylidar.toolbox.translate.spdv42las.setOutputScaling(points, indata, outdata)[source]

Sets the output scaling for las. Tries to copy scaling accross.

pylidar.toolbox.translate.spdv42las.transFunc(data)[source]

Called from pylidar. Does the actual conversion to las

pylidar.toolbox.translate.spdv42las.translate(info, infile, outfile, spatial=False, extent=None)[source]

Does the translation between SPD V4 and .las format files.

  • Info is a fileinfo object for the input file.
  • infile and outfile are paths to the input and output files respectively.
  • spatial is True or False - dictates whether we are processing spatially or not.
    If True then spatial index will be created on the output file on the fly.
  • extent is a tuple of values specifying the extent to work with.
    xmin ymin xmax ymax

Currently does not take any command line scaling options so LAS scaling will be the same as the SPDV4 input file scaling. Not sure if this is a problem or not…