[Liblas-devel] Extract Color from NAIP with python, libLAS, and GDAL

Howard Butler hobu.inc at gmail.com
Fri Jul 23 23:28:45 EDT 2010


Aaron,

I have taken your script and readapted it as a python utility.  I added a few flourishes as well, although it doesn't resummarize the header information for options like changing the SRS.

You will have to use the latest main branch of libLAS for this to work.  I haven't tested with 1.2, but I think there was a color referencing issue problem in the 1.2 python bindings that I fixed quite a while ago which might have caused your issue.

<http://hg.liblas.org/main/file/84eba420aa2b/python/scripts/colorize.py>

> fire:scripts hobu$ ./colorize.py --helpUsage: colorize.py [options] arg
> 
> Options:
>   -h, --help            show this help message and exit
> 
>   Base options:
>     Basic Colorization Options
> 
>     -o OUTPUT, --output=OUTPUT
>                         LAS file to write
>     -i INPUT, --input=INPUT
>                         LAS file to read
>     -r IMAGE, --image=IMAGE
>                         GDAL raster image to use for color
>     -b BANDS, --bands=BANDS
>                         Comma-separated list of bands numbers to use for R,G,B
>     -s, --scale         Scale the color values to 16 bit by multiplying by 256
>     -t TARGET_SRS, --target-srs=TARGET_SRS
>                         Output SRS for LAS file
>     -a ASSIGN_SRS, --assign-srs=ASSIGN_SRS
>                         Assign specified SRS for input LAS file
>     -w, --overwrite     overwrite the existing LAS output file
>     -q, --quiet         Don't say what we're doing on stdout


Here's some example usage to using your example data at <http://liblas.org/samples/Autzen_Stadium.zip>  This example assigns the UTM zone 10 UTM zone to the data as it is read, and then reprojects it to 4269 as it writes.  The utility doesn't scale the color data to 16 bit by default, and you must use the -s option to turn that on.  Another nifty feature is the ability to swap your bands around with a comma-separated list for RGB.

python colorize.py ~/hg/liblas/test/data/Autzen_Stadium/LAS/44123A1305_ALL.las ~/hg/liblas/test/data/Autzen_Stadium/naip_1_1_1n_s_or039_2005_1_C2.img --bands 1,2,3 -w -a EPSG:26910 -t EPSG:4269

Thanks for the great data.  This has plenty of room to be optimized further, but it's quite functional right now.  

Howard


More information about the Liblas-devel mailing list