[Liblas-devel] Extract and Apply color values to Las 1.2 from NAIP

Howard Butler hobu.inc at gmail.com
Thu Jun 17 21:41:57 EDT 2010


On Jun 17, 2010, at 7:03 PM, Aaron Reyna wrote:

> Hi everyone,
> 
> I would like to add color values to a .las 1.2 file and I have the corresponding .img NAIP with the same extent. I can use GDAL and LibLAS to get a color for each point based on the cell value it falls onto, but if anyone has any idea as how to apply that color in RGB value to the las file, it would be greatly appreciated.

I don't think you're going to be able to do this without writing some code at this time.  Here's the basic steps:

* Create a new liblas::Writer with a liblas::Header copied from your existing file with the following properties:
** Minor version: 2
** Point format: 2 or 3, depending on whether or not you want time
* Set up an liblas::Reader to read through your file
* For each point, query the GDALDataset to get the RGB (or other band) values
* Create a liblas::Color object, and set the RGB values of that to what you read from the GDALDataset, multiplying each by 256 (color values are supposed to be scaled to 16bit according to the spec, though not all softwares do this)
* Set the color object of the liblas::Point you read with the liblas::Reader
* Call liblas::Writer::WritePoint() into your new file

All of this would be possible with the current development version of the Python API in combination with GDAL's Python API too.  Just substitute the class names to protect the innocent :)

> 
> for instance, lets say for point Q the RGB values are 255, 255, 255, respectively.
> 
> Would one use las2las? Or should I write it all(x,y,z, intensity... etc.) to text files and then write those text files to las? The latter method seems like it might be rather slow for high resolution data. Any ideas would be greatly appreciated.

It would make a lot of sense to support this operation in las2las, as it is fairly useful and fairly common.  If you wish to provide a patch to implement it, or would like commit access to take it on, I would support that.  



More information about the Liblas-devel mailing list