Tag Archives: LAStools

Attribute LAS points using hyperspectral data

A good way of visualising LiDAR point clouds is to attribute them with colour information.
LAS files of point type 2 and above have the ability to store RGB colour information. These can be viewed with programs such as plas.io and CloudCompare.

To add RGB colour information to a LAS file ARSF-DAN have made a Python script available from: https://github.com/pmlrsg/arsf_tools

The script uses a combination of laspy (to read and write a LAS file) and GDAL (to read the raster) and is capable of working with images with more than 3 bands such as multispectral or hyperspectral files without creating a three band copy of the image first.

For this post I’ll demonstrate running the script on the JASMIN/CMEMS system. In a nutshell it is a Linux computing facility with lots of fast storage and direct access to many datasets, including the ARSF archive of airborne LiDAR and Hyperspectral data (apply for access to ARSF data here). Researchers in the UK who are part of the NERC or National Centre for Earth Observation (NCEO) scientific communities can apply for access. If you don’t have access to JASMIN you can run on your own machine just ignore the JASMIN specific steps.

  1. Apply for access and logon to JASMIN
    If you are using JASMIN the first stage is to get an account and log on by following the steps in this guide: http://jasmin.ac.uk/workflow/
  2. Set up scripts
    Once you have logged onto one of the shared VMs (e.g., cems-sci2.cems.rl.ac.uk) you need to load laspy, which isn’t installed by default. You can do this using:

    module load contrib/arsf/laspy/1.3.0
    

    Then checkout the repository containing the ‘colour_las_file.py’ script using:

    git clone https://github.com/pmlrsg/arsf_tools.git
    

    Check the script runs OK by typing:

    python2.7 arsf_tools/colour_las_file.py -h
    

    Note, you need to specify Python 2.7 as the default system Python is 2.6 but most of the Python libraries (e.g., GDAL) are build against 2.7. If you are not running the scripts on JASMIN just using ‘python’ should be fine.

  3. Colour using ARSF hyperspectral dataFor this example data from Mont Blanc flown as part of a EUFAR campaign in 2015 on Julian day 175a (24/06/2015) will be used. This data can be downloaded from NEODC (direct link).
    LIDAR_PATH=/neodc/arsf/2015/EUFAR15_28/EUFAR15_28-2015_175a_Mont_Blanc/LiDAR/flightlines/las1.2
    HS_PATH=/neodc/arsf/2015/EUFAR15_28/EUFAR15_28-2015_175a_Mont_Blanc/hyperspectral/flightlines/mapped
    
    python2.7 arsf_tools/colour_las_file.py \
              --image /vsizip/$HS_PATH/f175a183b_mapped_utm32n_bil.zip/f175a183b_mapped_utm32n.bil \
              --red 38 \
              --green 25 \
              --blue 12 \
              --scale \
             $LIDAR_PATH/LDR-EUFAR15_28-2015-175a-18.LAS \
             LDR-EUFAR15_28-2015-175a-18_col.LAS
    

    This will attribute using bands 38, 25 and 12 (true colour) and will scale the pixel values from 16 bit to 8 bit (0 – 255) using a standard deviation stretch.To read the hyperspectral data without unzipping a GDAL virtual file system is used, as described in a previous post.

  4. LASzip files and Download
    To reduce the size of the files before downloading you can use LASzip. On JASMIN LAStools can be loaded using:

    module load contrib/arsf/lastools/20150925
    

    To compress the LAS file and drop points flagged as noise the following command can be used:

    las2las -drop_class 7 -i LDR-EUFAR15_28-2015-175a-18_col.LAS -o LDR-EUFAR15_28-2015-175a-18_col.laz
    

    A similar command can be used to decompress files.

    See the following guide on transferring data off JASMIN: http://jasmin.ac.uk/how-to-use-jasmin/data-transfer/

  5. View using plas.io
  6. Open http://plas.io/ in a modern browser and click ‘Browse’ to load in the coloured LAS file.
    plasio_screenshot
    The nice thing about using plas.io and JASMIN is no specialist software needs to be installed on your local machine, just an ssh client and a web browser.

  7. View using Cloud Compare Viewer
  8. If you want to view files locally you can use Cloud Compare, which is available for Windows, OS X and Linux. To open the coloured LAS/LAZ file in the cloud compare viewer just drag it into the viewer window.

    cc_screenshot

  9. Additional – Colour using an existing three band image
    If you already have a three band image, with pixel values 0 – 255 a simpler command can be used:

    colour_las_file.py --image in_raster_file_rgb.tif \
                  in_las_file.las out_las_file.las