Page 1 of 1

Getting Invalid Step Size for Spatial Resampling with using Commandline CC

Posted: Wed Jun 14, 2023 8:55 pm
by mcaradonna

Code: Select all

@echo off
setlocal

rem Specify the paths to the CloudCompare executable and the input directory
set CLOUD_COMPARE_PATH="C:\Program Files\CloudCompare\CloudCompare.exe"
set INPUT_DIR="D:\test_input"
set OUTPUT_DIR="D:\test_output"

rem Specify the number of blocks
set BLOCK_COUNT=9

rem Create the output directory
mkdir %OUTPUT_DIR%


rem Specify Sub Sampling Density 

set SubSamplingDensity = 0.1 rem in meters


rem Process each .las file in the input directory
for %%F in ("%INPUT_DIR%\*.las") do (
    echo Processing file: %%~nxF
    
    rem Get the file name without extension
    set FILENAME=%%~nF
    
    rem Subsample the current file for each block
    for /L %%i in (1,1,%BLOCK_COUNT%) do (
        echo Subsampling Block %%i
        %CLOUD_COMPARE_PATH% -O "%%F" -C_EXPORT_FMT LAS -SS SPATIAL %SubSamplingDensity% -SAVE_CLOUDS %OUTPUT_DIR%\block_%%~nF_%%i.las -C_ALL_ATTRIBS
        
        rem Merge the current block with previous blocks
        if %%i gtr 1 (
            echo Merging Block %%i with previous blocks
            %CLOUD_COMPARE_PATH% -O @%OUTPUT_DIR%\block_files_%%i.txt -C_EXPORT_FMT LAS -SAVE_CLOUDS %OUTPUT_DIR%\merged_blocks_%%i.las -C_ALL_ATTRIBS
        ) else (
            rem Create the block files list for the first block
            echo %%F > %OUTPUT_DIR%\block_files_%%i.txt
        )
        
        rem Append the current file name to the block files list
        echo %%F >> %OUTPUT_DIR%\block_files_%%i.txt
    )
)

rem Merge all the block files into one large file
echo Merging all blocks into one file
%CLOUD_COMPARE_PATH% -O %OUTPUT_DIR%\merged_blocks_*.las -C_EXPORT_FMT LAS -SAVE_CLOUDS "D:\test_merged\merged.las" -C_ALL_ATTRIBS

echo Script execution completed.


endlocal
Do you guys see anything wrong with this code? I am trying to subsample, save and merge point cloud files.


I am getting this error
Capture.PNG
Capture.PNG (5.04 KiB) Viewed 2866 times

Re: Getting Invalid Step Size for Spatial Resampling with using Commandline CC

Posted: Thu Jun 15, 2023 5:06 pm
by daniel
What does a command like 'echo %SubSamplingDensity%' would output?

Re: Getting Invalid Step Size for Spatial Resampling with using Commandline CC

Posted: Mon Jun 19, 2023 12:54 pm
by mcaradonna
'echo %SubSamplingDensity%' would output the variable value.

So if you did

Code: Select all

set SubSamplingDensity = 0.1

echo %SubSamplingDensity%
echo would output 0.1 to the command prompt

Re: Getting Invalid Step Size for Spatial Resampling with using Commandline CC

Posted: Fri Jun 23, 2023 5:21 pm
by daniel
Hum, then I don't know! We would need a batch script expert...

(and I guess you've tried to replace %SubSamplingDensity% by 0.1 in the script to check that the problem comes from here?)

Re: Getting Invalid Step Size for Spatial Resampling with using Commandline CC

Posted: Tue Jun 27, 2023 1:48 pm
by mcaradonna
Yeah, I tried that.