Change LAS Class Codes (3D Analyst)
Summary
Modifies the class code values of LAS files referenced by a LAS dataset.
Usage
-
All LAS files referenced by the LAS dataset will be evaluated by this tool, but only the files that contain the provided class codes will be modified.
Consider using this tool to update the classification of data points in LAS files generated prior to the introduction of standardized class codes in the LAS 1.1 specifications.
LAS points can be classified into a number of categories that describe the material encountered by the lidar return, such as ground, building, or water. The American Society for Photogrammetry and Remote Sensing (ASPRS) defined the following class codes for LAS file versions 1.1, 1.2, and 1.3:
Classification Value
Classification Type
0
Never Classified
1
Unassigned
2
Ground
3
Low Vegetation
4
Medium Vegetation
5
High Vegetation
6
Building
7
Noise
8
Model Key
9
Water
10
Reserved for ASPRS Definition
11
Reserved for ASPRS Definition
12
Overlap
13–31
Reserved for ASPRS Definition
Syntax
Parameter | Explanation | Data Type |
in_las_dataset |
The input LAS dataset. | LAS Dataset Layer |
class_codes [[current_class new_class],...] | Specify each pair of current and new class code values as a space-delimited string or a list of integers. For example, a current class code of 5 can be changed to 2 by specifying "5 2" or [5, 2]. Multiple class codes can be entered as a semicolon-delimited string ("5 2; 8 3; 1 4"), a list of strings (for example, [[5, 2], [8, 3], [1, 4]]). | Value Table |
compute_stats (Optional) | Specifies whether statistics should be computed for the LAS files referenced by the LAS dataset. The presence of statistics allows the LAS dataset layer's filtering and symbology options to only show LAS attribute values that exist in the LAS files.
| Boolean |
Code Sample
The following sample demonstrates the use of this tool in the Python window:
import arcpy
from arcpy import env
arcpy.CheckOutExtension('3D')
env.workspace = 'C:/data'
arcpy.ChangeLasClassCodes_3d('test.lasd', [[5, 2], [3, 1], [4, 6]],
'COMPUTE_STATS')
The following sample demonstrates the use of this tool in a stand-alone Python script:
'''****************************************************************************
Name: Update LAS 1.0 Classification to ASPRS 1.1 Specs
Description: Updates classification of version 1.0 LAS files to conform to
the standardized class codes introduced in the 1.1 specifications.
The code is designed for use as a script tool.
****************************************************************************'''
# Import system modules
import arcpy
import exceptions, sys, traceback
# Set Local Variables
inLas = arcpy.GetParameterAsText(0)
recursion = arcpy.GetParameterAsText(1)
lasd = arcpy.GetParameterAsText(2)
reclassList = arcpy.GetParameterAsText(3) #List of values '<oldCode> <newCode>'
calcStats = arcpy.GetParameter(4)
try:
arcpy.CheckOutExtension('3D')
# Execute CreateLasDataset
arcpy.management.CreateLasDataset(inLas, lasd, recursion)
# Execute ChangeLasClassCodes
arcpy.ddd.ChangeLasClassCodes(lasd, reclassList, calcStats)
# Report messages
arcpy.GetMessages()
except arcpy.ExecuteError:
print arcpy.GetMessages()
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate error information into message string
pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
.format(tbinfo, str(sys.exc_info()[1]))
msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
# Return python error messages for script tool or Python Window
arcpy.AddError(pymsg)
arcpy.AddError(msgs)