3570
How to access the classification information in a LAS Lidar file using the programming interface (API)
ENVI Lidar can be used to read and view Lidar point clouds from LAS files. It can sometimes be useful to get information from the file without importing it to ENVI Lidar. The below code example shows how you can read the classification values held in a LAS file.
;--------------------------------
PRO getLASclassifications
COMPILE_OPT idl2
CATCH,err
IF err NE 0 THEN BEGIN
CATCH, /CANCEL
PRINT, 'Error: ' , !error_state.msg
MESSAGE,/RESET
IF OBJ_VALID(e) THEN BEGIN
e.CLOSE
ENDIF
RETURN
ENDIF
e = e3de(/headless)
;provide the name of the classified pointcloud
lasFileName = 'pointCloud_000.las'
;Directly read the input LAS file containing classification values
oLidar = e3de.openlidar(lasFileName, /DIRECT_READ)
startIndex = 0
blockSize = 500000
allread = 0
WHILE (allread eq 0) DO BEGIN
pointsInRange = oLidar.GetPointsInRange(startIndex, blockSize, $
ALL_ATTRIBS=ALL_ATTRIBS, $
COUNT=nPointsRead)
; *ALL_ATTRIBS.CLASSIFICATIONS returns the classification codes stored in
; the las file for this iteration of the WHILE LOOP
inClass = *ALL_ATTRIBS.CLASSIFICATIONS
IF (nPointsRead LT blocksize) THEN allread = 1
startIndex += nPointsRead
ENDWHILE
e.CLOSE
END
;-----------------------------
MM June 9, 2015