Monday, July 31, 2017

PDAL: Colorize a LAS file with multiple GeoTiff images

A LiDAR LAS file may not necessarily share the same bounds as a single raster image file. More often the case, to cover the LAS file more than one raster image file is needed. One way to resolve this is to merge all the raster images into a single mosaic file. Another way may be to keep the raster images as they are and load them in one by one (just-in-time fashion) to colorize the LAS file. This workflow is a little more complicated but it can be done using PDAL's pipeline processing mechanism.

In this post, PDAL will be used to colorize a LAS file using multiple tiles of GeoTIFF image files - four to be exact. You just need to create a pipeline that loads in the LAS file, apply the RGB values from each image file individually and write the colored points into an output LAS file. The following sections illustrate this workflow.

Here's how the source LAS and GeoTIFF files look like.
The source LiDAR LAS file displayed by elevation
The source GeoTIFF raster image files
Create a PDAL pipeline JSON file
  1. Using a text editor, type in the JSON syntax to colorize a LAS file using PDAL's colorization filter, as shown below.


    where
    uncompahgre.laz is the source LAS file,
    tile0.tif, tile1.tif, tile2.tif and tile3.tif are the source image files,
    and color.laz is the output LAS file name

  2. Save the text into a file e.g. colorLas.json.
A sample pipeline JSON is show in the listing below.

{
    "pipeline": [
        "uncompahgre.laz",
        {
            "type": "filters.colorization",
            "raster": "tile0.tif"
        },
        {
            "type": "filters.colorization",
            "raster": "tile1.tif"
        },
        {
            "type": "filters.colorization",
            "raster": "tile2.tif"
        },
        {
            "type": "filters.colorization",
            "raster": "tile3.tif"
        },
        {
            "type": "writers.las",
            "compression": "true",
            "minor_version": "2",
            "dataformat_id": "3",
            "filename":"color.laz"
        }
    ]
}

Run the colorization process

  1. Open up a OSGeo4W Command Prompt.
  2. At the prompt, type in the pdal pipeline command:

    c:\> pdal pipeline colorLas.json
    where colorLas.json is the pipeline JSON file created in the previous section.
  3. Run the command.

    Processing messages appear.


    The output colorized LAS file color.laz is generated.
  4. Optional. Display the resultant colored LAS file in a LAS Viewer.



No comments:

Related Posts with Thumbnails