gridindexutils¶
Common utility functions for dealing with grid spatial indices

pylidar.lidarformats.gridindexutils.
CreateSpatialIndex
(coordOne, coordTwo, binSize, coordOneMax, coordTwoMin, nRows, nCols, indexDtype, countDtype)[source]¶ Create a SPD grid spatial index given arrays of the coordinates of the elements.
This can then be used for writing a SPD V3/4 spatial index to file, or to rebin data to a new grid.
Any elements outside of the new spatial index are ignored and the arrays returned will not refer to them.
Parameters:
 coordOne is the coordinate corresponding to bin row.
 coordTwo corresponds to bin col.
 Note that coordOne will always be reversed, in keeping with widespread conventions that a Y coordinate increases going north, but a grid row number increases going south. This same assumption will be applied even when the coordinates are not cartesian (e.g. angles).
 binSize is the size (in world coords) of each bin. The V3/4 index definition
 requires that bins are square.
 coordOneMax and coordTwoMin define the top left of the
 spatial index to be built. This is the world coordinate of the topleft corner of the topleft bin
 nRows, nCols  size of the spatial index
 indexDtype is the numpy dtype for the index (si_start, below)
 countDtype is the numpy dtype for the count (si_count, below)
Returns:
 mask  a 1d array of bools of the valid elements. This must be applied
 before sortedBins.
 sortedBins  a 1d array of indices that is used to
 resort the data into the correct order for using the created spatial index. Since the spatial index puts all elements in the same bin together this is a very important step!
 si_start  a 2d array of start indexes into the sorted data (see
 above)
 si_count  the count of elements in each bin.

pylidar.lidarformats.gridindexutils.
SNAPMETHOD_GREATER
= 2¶ Constant for use with snapToGrid. Snaps to greater grid value

pylidar.lidarformats.gridindexutils.
SNAPMETHOD_LESS
= 1¶ Constant for use with snapToGrid. Snaps to lesser grid value

pylidar.lidarformats.gridindexutils.
SNAPMETHOD_NEAREST
= 0¶ Constant for use with snapToGrid. Snaps to nearest grid value

pylidar.lidarformats.gridindexutils.
convertSPDIdxToReadIdxAndMaskInfo
(start_idx_array, count_array, outSize=None)[source]¶ Convert either a 2d SPD spatial index or 1d index (pulse to points, pulse to waveform etc) information for reading with h5py and creating a masked array with the indices into the read subset.
Parameters:
 start_idx_array is the 2 or 1d input array of file start indices from SPD
 count_array is the 2 or 1d input array of element counts from SPD
 outSize is the size of the h5py dataset to be read. Set to None to not return the h5space.H5Space object
Returns:
 If outSize is not None, A h5space.H5Space object for reading and writing data.
 A 3 or 2d (depending on if a 2 or 1 array was input) array containing indices into the new subset of the data. This array is arranged so that the first axis contains the indices for each bin (or pulse) and the other axis is the row (and col axis for 3d output) This array can be used to rearrange the data ready from h5py into a ragged array of the correct shape constaining the data from each bin.
 A 3 or 2d (depending on if a 2 or 1 array was input) bool array that can be used as a mask in a masked array of the ragged array (above) of the actual data.

pylidar.lidarformats.gridindexutils.
getSlicesForExtent
(siPixGrid, siShape, overlap, xMin, xMax, yMin, yMax)[source]¶ xMin, xMax, yMin, yMax is the extent snapped to the pixGrid.