GeoTalks 2025 User Conference

Select Lidar within a certain distance of a KML Script

Hello, I am working to classify powerlines in lidar using the automatic classification. I am having the issues of many nonpowerlines being classified and to work around this in the GUI I used the select lidar by distance tool then I ran the poles/wires class on just the points selected in the digitizer. I need to replicate this process in the script and have been struggling to do so. This is my script so far. The EDIT_LIDAR function exports a cropped .las file, but I cannot get the results of the crop to merge back into my original file.                                                                                                                               //call global mapper script and version
GLOBAL_MAPPER_SCRIPT VERSION=1.00
LOG_MESSAGE 1- Script <%SCRIPT_FILENAME%> started at %DATE% %TIME%

UNLOAD_ALL 

//Time stamp
LOG_MESSAGE 2- %TIMESTAMP%:

// Importing a Directory
IMPORT_DIR_TREE DIRECTORY="G:\JGM\Global_mapper_scripts\Global_mapper_scripts" RECURSE_DIR=YES

// Starts loop within the specified directory only looking at .las files
DIR_LOOP_START DIRECTORY="G:\JGM\Global_mapper_scripts\Global_mapper_scripts" RECURSE_DIR=YES

// Imports each file into loop
IMPORT FILENAME="%FNAME_W_DIR%"
LOG_MESSAGE 3- Loaded file <%FNAME%> at %DATE% %TIME%

LOG_MESSAGE 4- Importing <%FNAME_W_DIR%> took: %TIME_SINCE_LAST_LOG% 

//Select Lidar by Distance tool Scripting option 

//Must Define Lidar filter to create a list of points to look at 
DEFINE_LIDAR_FILTER NAME="Noise_Ground_Filter" LIDAR_FILTER="ALL,-2,-7,-18" 

//Imports files
EDIT_LIDAR FILENAME="%FNAME_W_DIR%"\

//Uses the filter defined in "Define_Lidar_filter"
LIDAR_FILTER_NAME="Noise_Ground_Filter"\

//Specifies Max distance away from (in meters)
MAX_DIST=1.5\

//Disables the 3D search option which is the default
USE_3D_DIST=NO \

//KML or KMZ or shapefile or... of powerlines to look close to -- Must specify max dist
FILENAME_NEAR="G:\JGM\Global_mapper_scripts\Global_mapper_scripts\Coconuntgrove_20210811_.kmz"\

//Creats a new layer for selected points 
NEW_LAYER_NAME="Lidar_within_1.5m_of_powerlines" DELETE_FEATURES=NO

//Export layer to new directory
EXPORT_VECTOR EXPORT_LAYER="%FNAME_W_DIR%" TYPE="LIDAR_LAS" FILENAME="G:\JGM\Global_mapper_scripts\Global_mapper_scripts\GM_Script_Out\Select_by_Dist\Lidar_within_1.5m_of_powerlines.las"

DIR_LOOP_END

LOG MESSAGE 5- <%FNAME%> has been clipped to KMZ and Exported 

//Create a new loop that loops through output directory of first loop and classifys powerlines

// Importing a Directory
IMPORT_DIR_TREE DIRECTORY="G:\JGM\Global_mapper_scripts\Global_mapper_scripts\GM_Script_Out\Select_by_Dist"  RECURSE_DIR=YES

// Starts loop within the specified directory only looking at .las files
DIR_LOOP_START DIRECTORY="G:\JGM\Global_mapper_scripts\Global_mapper_scripts\GM_Script_Out\Select_by_Dist" RECURSE_DIR=YES

// Imports each file into loop
IMPORT FILENAME="%FNAME_W_DIR%"
LOG_MESSAGE 6- Loaded file <%FNAME%> at %DATE% %TIME%

LOG_MESSAGE 7- Importing <%FNAME_W_DIR%> took: %TIME_SINCE_LAST_LOG% 

//Powerline Classification 

DEFINE_LIDAR_FILTER NAME="Noise_Ground_filter" LIDAR_FILTER="ALL,-2,-7,-18"

LIDAR_CLASSIFY FILENAME=%FNAME_W_DIR% TYPE="POWERLINE"\
LIDAR_RESET_NON_GROUND=YES\
POWERLINE_BIN_SIZE="0.33"\
LIDAR_MIN_POWERLINE_HEIGHT="7"\
POWERLINE_MAX_DIST_FROM_LINE="0.4"\
POWERLINE_MAX_VERT_DIFF_PER_M="0.8"

// Pole Point Classification
LIDAR_CLASSIFY FILENAME=%FNAME_W_DIR% TYPE="POWERLINE"\
POLE_SMOOTH_COUNT="3"\
POLE_MIN_NEIGHBOR_DIS="0.22"\
POLE_MIN_LEN="4"\
POLE_MIN_COUNT="10"\
POLE_MIN_THRESHOLD="30"\
POLE_MAX_EXTENT="5.3"

LOG_MESSAGE 8- Utilities Classification took: %TIME_SINCE_LAST_LOG% for <%FNAME%>

//Export
EXPORT_VECTOR EXPORT_LAYER="%FNAME_W_DIR%" TYPE="LIDAR_LAS" FILENAME="G:\JGM\Global_mapper_scripts\Global_mapper_scripts\GM_Script_Out\Select_by_Dist\UtilitiesClass\%FNAME%_UtlitiesClass.las"

DIR_LOOP_END

LOG_MESSAGE 9- Clipped <%FNAME%> has been powerline classified
LOG_MESSAGE 10- Total Script Run Time: %TIME_SINCE_START%\


//create another loop that will put the powerline class back into original file by exporting the two files as one 

EXPORT_ELEVATION FILENAME="Newfilenmae and path to export data too"\
EXPORT_LAYER="Original las file w/out powerline class" \
EXPORT_LAYER="Cropped powerline classified file" \
ELEV_UNITS=METERS
Tagged: