-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples to use python scripts in the docker image
- Loading branch information
1 parent
48e339e
commit b27553b
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Example python script used to demonstrate the usage of local python scripts inside the pdal_ign_plugin | ||
docker image | ||
""" | ||
|
||
import argparse | ||
|
||
import pdal | ||
|
||
from pdal_ign_macro import version as pim_version | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-i", "--input_file", type=str, help="Input las/laz file on which to run the script" | ||
) | ||
parser.add_argument("-o", "--output_file", type=str, help="Out las/laz file of the script") | ||
return parser.parse_args() | ||
|
||
|
||
def main(input_file, output_file): | ||
print("Pdal version is:", pdal.__version__) | ||
print("pdal_ign_macro version is:", pim_version.__version__) | ||
print("Copy input file to output file as LAS1.4") | ||
pipeline = pdal.Pipeline() | ||
pipeline |= pdal.Reader.las(filename=input_file) | ||
pipeline |= pdal.Writer.las(filename=output_file, major_version=1, minor_version=4) | ||
pipeline.execute() | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
main(args.input_file, args.output_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# Bash script to run a local python script in the pdal_ign_plugin docker image | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-i|--input_file) | ||
input_dir=$(realpath $(dirname "$2")) | ||
input_filename=$(basename "$2") | ||
shift # past argument | ||
shift # past value | ||
;; | ||
-o|--output_dir) | ||
output_dir=$(realpath "$2") | ||
shift # past argument | ||
shift # past value | ||
;; | ||
-s|--script) | ||
script_dir=$(realpath $(dirname "$2")) | ||
script_filename=$(basename "$2") | ||
shift # past argument | ||
shift # past value | ||
;; | ||
*) | ||
echo "Unknown option $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
echo "Run script:" | ||
echo "* dir=${script_dir}" | ||
echo "* name=${script_filename}" | ||
echo "on file:" | ||
echo "* dir=${input_dir}" | ||
echo "* name=${input_filename}" | ||
echo "save output to:" | ||
echo "* dir=${output_dir}" | ||
echo "* name=${input_filename}" | ||
echo "--------" | ||
|
||
|
||
docker run --rm --userns=host \ | ||
-v ${input_dir}:/input \ | ||
-v ${output_dir}:/output \ | ||
-v ${script_dir}:/script \ | ||
ghcr.io/ignf/pdal-ign-plugin:latest \ | ||
python /script/${script_filename} \ | ||
-i /input/${input_filename} \ | ||
-o /output/${input_filename} |