In PDAL, a pipeline file can be used to do a variety of operations. Within the following context, I think of a pipeline file like an ad hoc preferences file, where I can use an external command to iterate through the things I want to change, while holding constant everything else in the pipeline file.
In my use case for this vignette, I’ll use the pipeline file to hold my database preferences for putting the point clouds into my PostGIS database. For the record, I’m using vpicavet’s docker pggis as the starting place for installing PostGIS with the pgpointcloud extension. I have adapted the following pipeline file from the PDAL writers.pgpointcloud example.
<?xml version="1.0" encoding="utf-8"?> <Pipeline version="1.0"> <Writer type="writers.pgpointcloud"> <Option name="connection"> host='localhost' dbname=‘lidar’ user='user' password=‘password’ </Option> <Option name="table">54001640PAN_heightasz_0-1.5</Option> <Option name="compression">dimensional</Option> <!-- <Option name="srid">3270</Option> --> <Filter type="filters.chipper"> <Option name="capacity">400</Option> <Reader type="readers.las"> <Option name="filename">54001640PAN_heightasz_0-1.5.las</Option> <!-- <Option name="spatialreference">EPSG:3270</Option> --> </Reader> </Filter> </Writer> </Pipeline>
Some things to note. I have commented out the SRID and readers.las.spatialreference in the XML above. We’ll rely on PDAL to discover this, and use the default output of epsg:4326 to store our point clouds for the time being.
Our wrapper script for the pipeline file is very simple. We will use the wrapper script to specify the table and the input file name.
#!/bin/bash TABLE=`basename $1 .bpf` INPUT=$1 #echo $TABLE pdal pipeline -i pipeline.xml --writers.pgpointcloud.table=$TABLE --readers.bpf.filename=$INPUT
Now to use, we’ll use GNU Parallel, as much for it’s XArgs like functionality as scalability:
ls *.bpf | parallel -j6 ./pipeliner.sh {}
Now we can see what tables got loaded:
psql -d lidar psql (9.5.0) Type "help" for help. lidar=# \dt List of relations Schema | Name | Type | Owner --------+-------------------------------+-------+--------- public | 54001640PAN_heightasz_0-1.5 | table | user public | 54001640PAN_heightasz_1.5-6 | table | user public | 54001640PAN_heightasz_100-200 | table | user public | 54001640PAN_heightasz_30-45 | table | user public | 54001640PAN_heightasz_45-55 | table | user public | 54001640PAN_heightasz_55-65 | table | user public | 54001640PAN_heightasz_6-30 | table | user public | 54001640PAN_heightasz_65-75 | table | user public | 54001640PAN_heightasz_75-85 | table | user public | 54001640PAN_heightasz_85-100 | table | user public | pointcloud_formats | table | user public | spatial_ref_sys | table | user (12 rows)
W00t! We’ve got point clouds in our database! Next, we will visualize the data, and extract some analyses from it.