Hi Ben,
here some scripts which will do the job:
The basic (Windows/DOS) script extract the gps seconds from lasinfo and crop the given amount of seconds at the beginning of the file:
@echo off
rem #############################################################
rem # small batch file to crop the first n (arg 2) seconds of 1 or many las files (arg 1)
rem # by rapidlasso (https://rapidlasso.de)
rem #############################################################
if ["%1"]==[""] goto help
if ["%2"]==[""] goto help
goto start
:help
echo Batch to crop the first n seconds of a LAS/LAZ file
echo.
echo crop_first_n_seconds file secs [args]
echo.
echo file LAS/LAZ file
echo secs seconds to crop from beginning
echo args args for las2las
goto eof
:start
set fnin=%1
set tmpfile=tmp.txt
set odix=_out
set olsz=laz
lasinfo64 -i %fnin% -stop_at_point 1000 -stdout > %tmpfile%
for /f "delims=" %%a in ('awk "/gps_time/{print int($2)}" %tmpfile%') do (
set "gpsmin=%%a"
)
set /a gpsmin+=%2
las2las64 -i %fnin% -odix %odix% -o%olsz% -drop_gpstime_below %gpsmin% %3
set "fnout=%fnin:~0,-4%%odix%.%olsz%"
if not exist "%fnout%" (
echo no file "%fnout%" written. maybe invalid gps offset.
)
:eof
lets call this script "crop_first_n_seconds.cmd".
Then you can use a loop-script to call this one for every file in your directory (recursive):
:: @echo off
rem #############################################################
rem # small batch file to call a script for every file found
rem # by rapidlasso (https://rapidlasso.de)
rem #############################################################
if ["%1"]==[""] goto help
if ["%2"]==[""] goto help
goto start
:help
echo Batch to call a batch for every file found in given directory
echo.
echo for_all_files dir call args
echo.
echo dir directory to scan
echo call command or batchfile
echo args arguments for call
goto eof
:start
FOR /f %%G IN ('dir /b /s %1') DO (call %2 %%G %3 %4 %5 %6 %7)
:eof
we name this script "for_all_files.cmd"
If we call
for_all_files.cmd *.laz crop_first_n_seconds.cmd 5 -v
we create copies of the original files with the suffix "_out.laz"
which contain all data exclude the first 5 seconds.
Notes:
See the las2las ... part in the script to modify your output (directory, suffix, file format).
We only parse the first 1000 points within your file to get the minimum timestamp for performance reasons.
Please adjust this ("-stop_at_point 1000") if your minimum timestamp may exceed this range.
Enjoy the scripts!
Jochen @rapidlasso