X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



7163 Rate this article:
5.0

How to extract and apply LAS classification RGB values to a point cloud using the programming interface (API)

The following example code show how to access the classification values in a LAS file and create a new project file that will display the point cloud by the classification RGB values.  This example uses the default Computed Classification Values described in the ENVI Lidar help.  The values may vary depending on the LAS file version:

 

Computed
Classification Value

  Description

 0

  Not processed

 1

  Unclassified

 2

  Terrain

 3

  Near terrain

 5

  Trees

 6

  Buildings

14

  Power line

15

  Power pole

  

;----------------------------------------------------

PRO setRGBbyClassificationStoredInLAS

  COMPILE_OPT idl2

  e = e3de(/headless)

  ;lasFile has classification values already written to it
  lasFileName = 'classificationIn.las'

  ;create a project from the las file
  oLidar = e.openlidar(lasFileName)

  startIndex = 0
  blockSize = 500000
  allClass = MAKE_ARRAY(blockSize, /BYTE)

  allread = 0

  ;Loop through all points, setting the RGB value based on the stored
  ;classification values of the points
  WHILE (allread eq 0) DO BEGIN
    pointsInRange = oLidar.GetPointsInRange(startIndex, blockSize, $
      ALL_ATTRIBS=ALL_ATTRIBS, $
      COUNT=nPointsRead)

    ;inClass holds the Classifications for this iteration of the While loop
    inClass = *ALL_ATTRIBS.CLASSIFICATIONS
    IF (nPointsRead LT blocksize) THEN allread = 1

    ;allClass holds all of the Classifications in the file
    allClass = [allClass,inClass]

    ;uniqAllClass is an array containing one entry for each unique Classification
    uniqAllClass = allClass[UNIQ(allClass, SORT(allClass))]

    rgb = MAKE_ARRAY(3,nPointsRead, /BYTE)
    FOREACH i, uniqAllClass DO BEGIN
      CASE i OF
        ;Add all possible product types - powerpole, nearterrain… setting the rgb values to the corresponding classification color.
        ;Unprocessed
        0: BEGIN
          index = WHERE(inClass EQ 0)
          red=190
          green=190
          blue=190
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END

        ;Unclassified
        1: BEGIN
          index = WHERE(inClass EQ 1)
          red=255
          green=255
          blue=255
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END

        ;Terrain
        2: BEGIN
          index = WHERE(inClass EQ 2)
          red=255
          green=177
          blue=100
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END

        ;Near Terrain
        3: BEGIN
          index = WHERE(inClass EQ 3)
          red=128
          green=255
          blue=0
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END

        ;Trees
        5: BEGIN
          index = WHERE(inClass EQ 5)
          red=0
          green=147
          blue=0
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END

        ;Buildings
        6: BEGIN
          index = WHERE(inClass EQ 6)
          red=217
          green=217
          blue=0
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END

        ;Power lines
        14: BEGIN
          index = WHERE(inClass EQ 14)
          red=255
          green=100
          blue=255
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END

        ;Power poles
        15: BEGIN
          index = WHERE(inClass EQ 15)
          red=160
          green=80
          blue=0
          rgb[0,index] = red
          rgb[1,index] = green
          rgb[2,index] = blue
        END
        ELSE: PRINT, 'Bad value'
      ENDCASE
    ENDFOREACH

    startIndex += nPointsRead
  ENDWHILE

  e.CLOSE
END

;--------------------------------

MM June 12, 2015

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »