Getting Invalid Step Size for Spatial Resampling with using Commandline CC

Feel free to ask any question here
Post Reply
mcaradonna
Posts: 7
Joined: Wed Jun 14, 2023 8:52 pm

Getting Invalid Step Size for Spatial Resampling with using Commandline CC

Post 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 1505 times
daniel
Site Admin
Posts: 7427
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

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

Post by daniel »

What does a command like 'echo %SubSamplingDensity%' would output?
Daniel, CloudCompare admin
mcaradonna
Posts: 7
Joined: Wed Jun 14, 2023 8:52 pm

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

Post 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
daniel
Site Admin
Posts: 7427
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

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

Post 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?)
Daniel, CloudCompare admin
mcaradonna
Posts: 7
Joined: Wed Jun 14, 2023 8:52 pm

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

Post by mcaradonna »

Yeah, I tried that.
Post Reply