LiDAR Processor

Classes that are passed to the doProcessing function. And the doProcessing function itself

pylidar.lidarprocessor.ARRAY_TYPE_POINTS = 0

For use in userclass.LidarData.translateFieldNames() and LiDARFile.getTranslationDict()

pylidar.lidarprocessor.ARRAY_TYPE_PULSES = 1

For use in userclass.LidarData.translateFieldNames() and LiDARFile.getTranslationDict()

pylidar.lidarprocessor.ARRAY_TYPE_WAVEFORMS = 2

For use in userclass.LidarData.translateFieldNames() and LiDARFile.getTranslationDict()

pylidar.lidarprocessor.BOUNDS_FROM_REFERENCE = <Mock name='mock.imageio.BOUNDS_FROM_REFERENCE' id='140501630780688'>

to be passed to Controls.setFootprint()

pylidar.lidarprocessor.CLASSIFICATION_BRANCH = 102

Extended classification codes

pylidar.lidarprocessor.CLASSIFICATION_BRIDGE = 12

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_BUILDING = 6

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_CREATED = 0

Classification codes from the LAS spec. Drivers perform automatic translation to/from their internal codes for recognised values.

pylidar.lidarprocessor.CLASSIFICATION_FOLIAGE = 101

Extended classification codes

pylidar.lidarprocessor.CLASSIFICATION_GROUND = 2

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_HIGHPOINT = 8

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_HIGHVEGE = 5

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_INSULATOR = 16

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_LOWPOINT = 7

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_LOWVEGE = 3

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_MEDVEGE = 4

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_RAIL = 10

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_ROAD = 11

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_TRANSTOWER = 15

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_TRUNK = 100

Extended classification codes

pylidar.lidarprocessor.CLASSIFICATION_UNCLASSIFIED = 1

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_WATER = 9

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_WIRECOND = 14

Classification codes from the LAS spec.

pylidar.lidarprocessor.CLASSIFICATION_WIREGUARD = 13

Classification codes from the LAS spec.

pylidar.lidarprocessor.CREATE = 2

to be passed to ImageData and LidarData class constructors

class pylidar.lidarprocessor.Controls[source]

The controls object. This is passed to the doProcessing function and contains methods for controling the behaviour of the processing.

setFootprint(footprint)[source]

Set the footprint of the processing area. This should be either INTERSECTION, UNION or BOUNDS_FROM_REFERENCE.

Note: setting spatial processing to True now deprecated. Consider updating your code.

setMessageHandler(messageHandler)[source]

Set the message handler function to use for printing messages regarding things discovered during the processing. The default behaviour is to print all messages.

Can pass in silentMessageFn which will print nothing, or your own function that takes a message string and a level (one of the MESSAGE_* constants).

setOverlap(overlap)[source]

Sets the overlap between each window. In bins.

Note: setting spatial processing to True now deprecated. Consider updating your code.

setProgress(progress)[source]

Set the progress instance to use. Usually one of rios.cuiprogress.* Default is silent progress

setReferenceImage(referenceImage)[source]

The path to a reference GDAL image to use when the footprint is set to BOUNDS_FROM_REFERENCE. Set only one of this or referencePixgrid not both.

Note: setting spatial processing to True now deprecated. Consider updating your code.

setReferencePixgrid(referencePixgrid)[source]

The instance of rios.pixelgrid.PixelGridDefn to use as a reference when footprint is set to BOUNDS_FROM_REFERENCE. Set only one of this or referenceImage, not both.

Note: setting spatial processing to True now deprecated. Consider updating your code.

setReferenceResolution(resolution)[source]

Overrides the resolution that the processing happens with. Overrides either of the setReferenceImage or setReferencePixgrid calls or the default reference.

Note: setting spatial processing to True now deprecated. Consider updating your code.

setSnapGrid(snap)[source]

Snap the output grid to be multiples of the resolution. This is only needed when ReferenceResolution is not set. True or False.

Note: setting spatial processing to True now deprecated. Consider updating your code.

setSpatialProcessing(spatial)[source]

Set whether to do processing in a spatial manner. If set to True and if one of more LiDAR inputs do not support spatial indexing will be reset to False and warning printed.

Note: setting spatial processing to True now deprecated. Consider updating your code.

setWindowSize(size)[source]

Size of the window in bins/pixels that the processing is to be performed in. Same in the X and Y direction. If doing non spatial processing ‘size*size’ pulses are read in at each iteration.

pylidar.lidarprocessor.DEFAULT_WINDOW_SIZE = 256

Size of the default window size in bins

class pylidar.lidarprocessor.DataFiles[source]

Container class that has all instances of LidarFile and ImageFile inserted into it as the names they are to be used inside the users function.

pylidar.lidarprocessor.INTERSECTION = <Mock name='mock.imageio.INTERSECTION' id='140501627002128'>

to be passed to Controls.setFootprint()

class pylidar.lidarprocessor.ImageFile(fname, mode)[source]
setRasterDriver(driverName)[source]

Set GDAL driver short name to use for output format.

setRasterDriverOptions(options)[source]

Set a list of strings in driver specific format. See GDAL documentation.

setRasterIgnore(ignore)[source]

Set the ignore value for calculating statistics

class pylidar.lidarprocessor.LidarFile(fname, mode)[source]

Create an instance of this to process a LiDAR file. Set it to a field within your instance of DataFiles. The mode is one of: READ, UPDATE or CREATE.

setLiDARDriver(driverName)[source]

Set the name of the Lidar driver to use for creaton

setLiDARDriverOption(key, value)[source]

Set a key and value that the specific driver understands

setWriteSpatialIndex(writeSpatialIndex)[source]

Set whether to write spatial index or not on creation or update. Ignored for reading.

pylidar.lidarprocessor.MESSAGE_DEBUG = 2

to be passed to message handler function set with Controls.setMessageHandler

pylidar.lidarprocessor.MESSAGE_INFORMATION = 1

to be passed to message handler function set with Controls.setMessageHandler

pylidar.lidarprocessor.MESSAGE_WARNING = 0

to be passed to message handler function set with Controls.setMessageHandler

class pylidar.lidarprocessor.OtherArgs[source]

Container class that has any arbitary information that the user function requires. Set in the same form as DataFiles above, but no conversion of the contents happens.

pylidar.lidarprocessor.READ = 0

to be passed to ImageData and LidarData class constructors

pylidar.lidarprocessor.UNION = <Mock name='mock.imageio.UNION' id='140501632253008'>

to be passed to Controls.setFootprint()

pylidar.lidarprocessor.UPDATE = 1

to be passed to ImageData and LidarData class constructors

pylidar.lidarprocessor.defaultMessageFn(message, level)[source]

Default message printer. Prints all messages regardless of level.

Change with Controls.setMessageHandler

pylidar.lidarprocessor.doProcessing(userFunc, dataFiles, otherArgs=None, controls=None)[source]

Main function in PyLidar. Calls function userFunc with each block of data. dataFiles to be an instance of DataFiles with fields of instances of LidarFile and ImageFile. The names of the fields are re-used in the object passed to userFunc that contains the actual data.

If otherArgs (an instance of OtherArgs) is not None, this is passed as
the second param to userFunc.
If controls (an instance of Controls) is not None then these controls
are used for changing the behaviour of reading and writing.
pylidar.lidarprocessor.findCommonPixelGridRegion(gridList, refGrid, combine=<Mock name='mock.imageio.INTERSECTION' id='140501627002128'>)[source]

Returns a PixelGridDefn for the combination of all the grids in the given gridList. The output grid is in the same coordinate system as the reference grid.

This is adapted from the original in RIOS. This version does not attempt to reproject between coordinate systems. Firstly, because many LiDAR files do not seem to have the projection set. Secondly, we don’t support reprojection anyway - unlike RIOS.

The combine parameter controls whether UNION, INTERSECTION or BOUNDS_FROM_REFERENCE is performed.

pylidar.lidarprocessor.getWorkingPixGrid(controls, userContainer, gridList, driverList)[source]

Calculates the working pixel grid and informs the drivers and userContainer.

pylidar.lidarprocessor.openFiles(dataFiles, userContainer, controls)[source]

Open all the files required by doProcessing

pylidar.lidarprocessor.setDefaultDrivers()[source]

Adapted from RIOS Sets some default values into global variables, defining what defaults we should use for GDAL and LiDAR drivers. On any given output file these can be over-ridden, and can be over-ridden globally using the environment variables (for GDAL):

  • $PYLIDAR_DFLT_RASTERDRIVER
  • $PYLIDAR_DFLT_RASTERDRIVEROPTIONS

(And for LiDAR):

  • $PYLIDAR_DFLT_LIDARDRIVER

If PYLIDAR_DFLT_RASTERDRIVER is set, then it should be a gdal short driver name If PYLIDAR_DFLT_RASTERDRIVEROPTIONS is set, it should be a space-separated list of driver creation options, e.g. “COMPRESS=LZW TILED=YES”, and should be appropriate for the selected GDAL driver. This can also be ‘None’ in which case an empty list of creation options is passed to the driver.

If not otherwise supplied, the default is to use what RIOS is set to. This defaults to the HFA driver with compression.

If PYLIDAR_DFLT_LIDARDRIVER is set, then is should be a LiDAR driver name If not otherwise supplied, the default is to use the SPDV4 driver.

pylidar.lidarprocessor.silentMessageFn(message, level)[source]

Alternate message printer - does nothing.