Advanced las filtering and manipulation
las2las \kx [OPTIONS]
las2las reads and writes LiDAR data in the ASPRS LAS 1.0, 1.1, and 1.2 formats while modifying its contents. las2las is designed for filtering and transformation operations of LAS files.
While lasinfo(1), can do a few simple operations like updating header information, more drastic changes, like removing points or altering values, will require las2las. las2las is expected to be used for modifying single files at a time, and some las2las operations require multiple read passes through the points. Some examples of operations las2las can be used for include:
•
clipping of points to those that lie within a certain region specified by a bounding box (\*(T<--extent\*(T>)
•
eliminating points that are the second return (\*(T<--drop-return 2\*(T>),
•
eliminating points that have a scan angle above some threshold (\*(T<--drop-scan-angle "<5"\*(T>)
•
eliminating points that have an intensity below some threshold (\*(T<--drop-intensity "<15"\*(T>)
•
extracting only first (\*(T<--first-only\*(T>) or last (\*(T<--last-only\*(T>) returns
•
changing the format from LAS 1.0 to 1.1 or vice versa
•
eliminating points of a given classification (\*(T<--eliminate class 2\*(T>)
las2las started a port of Martin Isenburg's las2las utility from \$2 \(la\$1\(ra\$3 to the libLAS library. It is much-improved from his version, however, and provides a number of additional capabilities.
See also. contains background information on the port of Isenburg and Shewchuck's utilities to the libLAS library.
•
Text output describing the operation(s) is only provided when the \*(T<--verbose\*(T> (\*(T<-v\*(T>) switch is provided. Errors are reported to stderr.
•
Coordinate reprojection, including vertical datum transformation when compiled with the latest .
•
Coordinate system description and alteration.
•
Variable Length Records (VLRs) are carried forward by default.
•
VLR alteration, including adding your own VLRs with files and removal of VLRs
•
File splitting based on a specified file size (\*(T<--split-mb\*(T>) or points (\*(T<--split-pts\*(T>)
•
Ability to set coordinate offsets to minimum values of the existing coordinate space.
•
Color filtering
las2las2 options:
\*(T<-h\*(T>, \*(T<--help\*(T>
produce help message
\*(T<--split-mb\*(T> arg (=0)
Split file into multiple files with each being this size in MB or less. If this value is 0, no splitting is done
\*(T<--split-pts\*(T> arg (=0)
Split file into multiple files with each being this many points or less. If this value is 0, no splitting is done
\*(T<-i\*(T> arg, \*(T<--input\*(T> arg
input LAS file
\*(T<-o\*(T> arg, \*(T<--output\*(T> arg (=output.las)
output LAS file
\*(T<-v\*(T>, \*(T<--verbose\*(T>
Verbose message output
Header modification options:
\*(T<--a_srs\*(T> arg
Coordinate system to assign to input LAS file
\*(T<--a_vertcs\*(T> arg
Override vertical coordinate system information. Use \*(T<--a_vertcs "verticalCSType [citation [verticalDatum [verticalUnits]]]"\*(T> For example: \*(T<--a_vertcs 5703 "North American Vertical Datum of 1988 (NAVD88)" 5103 9001\*(T>
\*(T<--offset\*(T> arg
A comma-separated or quoted, space-separated list of offsets to set on the output file: \*(T<--offset 0,0,0\*(T> \*(T<--offset "1234 5678 91011"\*(T>
\*(T<--scale\*(T> arg
A list of scales to set on the output file. Scales cannot be negative, and should always be a negative power of 10: \*(T<--scale 0.1 0.1 0.00001\*(T>
\*(T<-f\*(T> arg, \*(T<--file-format\*(T> arg
Set the LAS format of the new file (only 1.0-1.2 supported at this time): \*(T<--file-format 1.2\*(T> \*(T<-f 1.1\*(T>
\*(T<--point-format\*(T> arg
Set the LAS point format of the new file (0, 1, 2, 3): \*(T<--point-format 3\*(T>
\*(T<--pad-header\*(T> arg
Add extra bytes to the existing header
\*(T<--min-offset\*(T>
Set the offset of the header to the minimums of all values in the file. Note that this requires multiple read passes through the file to achieve.
\*(T<--file-creation\*(T> arg
Set the header's day/year. Specify either as "1 2010" for the first day of 2010, or as "now" to specify the current day/year
\*(T<--add-schema\*(T>
Add the liblas.org schema VLR record to the file.
\*(T<--delete-vlr\*(T> arg
Removes VLRs with the given name and id combination. \*(T<--delete-vlr LASF_Projection 34737\*(T>
\*(T<--add-vlr\*(T> arg
Add VLRs with the given name and id combination. \*(T<--add-vlr hobu 1234 "Description of the VLR" "filename.ext"\*(T>
\*(T<--system-identifier\*(T> arg
Set the SystemID for the file. \*(T<--system-identifier "MODIFICATION"\*(T>
\*(T<--generating-software\*(T> arg
Set the SoftwareID for the file. \*(T<--generating-software "liblas.org"\*(T>
Transformation options:
\*(T<--t_srs\*(T> arg
Coordinate system to reproject output LAS file to. Use \*(T<--a_srs\*(T> or verify that your input LAS file has a coordinate system according to lasinfo
\*(T<--point-translate\*(T> arg
An expression to translate the X, Y, Z values of the point. For example, converting Z units that are in meters to feet: \*(T<--point-translate "x*1.0 y*1.0 z*3.2808399"\*(T>
\*(T<--color-source\*(T> arg
A string to a GDAL-openable raster data source. Use GDAL VRTs if you want to adjust the data source or set its coordinate system, etc. \*(T<--color-source "afile.tif"\*(T>
\*(T<--color-source-bands\*(T> arg
A list of three bands from the \*(T<--color-source\*(T> to assign to the R, G, B values for the point \*(T<--color-source-bands 1 2 3\*(T>
\*(T<--color-source-scale\*(T> arg
A number used by \*(T<--color-source\*(T> to scale the input R, G, B values for the point. For example, to scale the 8 bit color data from an input raster to 16 bit, the 8 bit data should be multiplied by 257. \*(T<--color-source-scale 256\*(T>
Filtering options:
\*(T<-e\*(T> arg, \*(T<--extent\*(T> arg
Extent window that points must fall within to keep. Use a comma-separated or quoted, space-separated list, for example, \*(T<-e minx, miny, maxx, maxy\*(T> or \*(T<-e minx, miny, minz, maxx, maxy, maxz\*(T> \*(T<-e "minx miny minz maxx maxy maxz"\*(T>
\*(T<--minx\*(T> arg
Extent must be greater than or equal to minx to be kept. \*(T<--minx 1234.0\*(T>
\*(T<--miny\*(T> arg
Extent must be greater than or equal to miny to be kept. \*(T<--miny 5678.0\*(T>
\*(T<--minz\*(T> arg
Extent must be greater than or equal to minz to be kept. If maxx and maxy are set but not minz *and maxz, all z values are kept. \*(T<--minz 0.0\*(T>
\*(T<--maxx\*(T> arg
Extent must be less than or equal to maxx to be kept. \*(T<--maxx 1234.0\*(T>
\*(T<--maxy\*(T> arg
Extent must be less than or equal to maxy to be kept. \*(T<--maxy 5678.0\*(T>
\*(T<--maxz\*(T> arg
Extent must be less than or equal to maxz to be kept. If maxx and maxy are set but not maxz *and minz, all z values are kept. \*(T<--maxz 10.0\*(T>
\*(T<-t\*(T> arg, \*(T<--thin\*(T> arg (=0)
Simple decimation-style thinning. Thin the file by removing every t'th point from the file.
\*(T<--last-return-only\*(T>
Keep last returns (cannot be used with \*(T<--first-return-only\*(T>)
\*(T<--first-return-only\*(T>
Keep first returns (cannot be used with \*(T<--last-return-only\*(T>)
\*(T<--keep-returns\*(T> arg
A list of return numbers to keep in the output file: \*(T<--keep-returns 1 2 3\*(T>
\*(T<--drop-returns\*(T> arg
Return numbers to drop. For example, \*(T<--drop-returns 2 3 4 5\*(T>
\*(T<--valid_only\*(T>
Keep only valid points
\*(T<--keep-classes\*(T> arg
A list of classifications to keep: \*(T<--keep-classes 2 4 12\*(T> \*(T<--keep-classes 2\*(T>
\*(T<--drop-classes\*(T> arg
A comma-separated list of classifications to drop: \*(T<--drop-classes 1,7,8\*(T> \*(T<--drop-classes 2\*(T>
\*(T<--keep-intensity\*(T> arg
Range in which to keep intensity. The following expression types are supported: \*(T<--keep-intensity 0-100\*(T> \*(T<--keep-intensity <200\*(T> \*(T<--keep-intensity >400\*(T> \*(T<--keep-intensity >=200\*(T>
\*(T<--drop-intensity\*(T> arg
Range in which to drop intensity. The following expression types are supported: \*(T<--drop-intensity <200 \*(T> \*(T<--drop-intensity >400 \*(T> \*(T<--drop-intensity >=200\*(T>
\*(T<--keep-time\*(T> arg
Range in which to keep time. The following expression types are supported: \*(T<--keep-time 413665.2336-414092.8462\*(T> \*(T<--keep-time <414094.8462\*(T> \*(T<--keep-time >413665.2336\*(T> \*(T<--keep-time >=413665.2336\*(T>
\*(T<--drop-time\*(T> arg
Range in which to drop time. The following expression types are supported: \*(T<--drop-time <413666.2336 \*(T> \*(T<--drop-time >413665.2336 \*(T> \*(T<--drop-time >=413665.2336\*(T>
\*(T<--keep-scan-angle\*(T> arg
Range in which to keep scan angle. The following expression types are supported: \*(T<--keep-scan-angle 0-100\*(T> \*(T<--keep-scan-angle <100\*(T> \*(T<--keep-scan-angle <=100\*(T>
\*(T<--drop-scan-angle\*(T> arg
Range in which to drop scan angle. The following expression types are supported: \*(T<--drop-scan-angle <30\*(T> \*(T<--drop-scan-angle >100\*(T> \*(T<--drop-scan-angle >=100\*(T>
\*(T<--keep-color\*(T> arg
Range in which to keep colors. Define colors as two 3-tuples (R,G,B-R,G,B): \*(T<--keep-color '0,0,0-125,125,125'\*(T>
\*(T<--drop-color\*(T> arg
Range in which to drop colors. Define colors as two 3-tuples (R,G,B-R,G,B): \*(T<--drop-color '255,255,255-65536,65536,65536'\*(T>
For more information, see the full documentation for las2las2 at: \(lahttp://liblas.org/utilities/las2las2.html\(ra
Clipping with a rectangle
\*(T< $ las2las in.las --output out.las --extent "63025000 483450000 63050000 483475000" \*(T>
clips points of in.las with x<=63025000 and y<=483450000 or x>=63050000 and y>=483475000 and stores surviving points to out.las.
\*(T< $ las2las in.las --output out.las --extent "63025000 483450000 0 63050000 483475000 100"" \*(T>
clips points of in.las with x <= 63025000 and y <= 483450000 and z <= 100 or x >= 63050000 and y >= 483475000 and z >= 0
note. The quotes around the extent values are important to aid the command line parsing. An error will likely result of not quoting the values. Alternatively, you can use commas to separate the \*(T<--extent\*(T> parameters to avoid quoting.
Eliminating specified returns
\*(T< $ las2las --input in.las --output out.las --drop-returns 1 \*(T>
eliminates all points of in.las that are designated first returns by the value in their return_number field and stores surviving points to out.las.
\*(T< $ las2las --input in.las --output out.las --drop-returns 2 3 4 5 \*(T>
eliminates all returns in the specified list.
Limiting based on scan angle
\*(T< $ las2las --input in.las --output out.las --keep-scan-angle "<=15" \*(T>
keeps all points of in.las whose scan angle is <= 15.
Limiting based on intensity
\*(T< $ las2las --input in.las --output out.las --drop-intensity "<=1000" \*(T>
eliminates all points of in.las whose intensity is below 1000 and stores surviving points to out.las.
Extract last returns
\*(T< $ las2las --input in.las --output out.las --last-return-only \*(T>
extracts all last return points from in.las and stores them to out.las.
Throw out invalid data
\*(T< $ las2las --input in.las --output out.las --valid-only \*(T>
removes invalid (according to the ASPRS LAS file format specification) points. This switch should only be required in a few special circumstances. Points that might be invalid include those with larger-than-required scan angles.
Eliminate ground points
\*(T< $ las2las --input in.las --output out.las --drop-classes 2 \*(T>
removes points with that have a classification of 2. Points with a classification of 2 are conventionally called ground points, but that convention may not be followed for older LAS 1.0 files.
Eliminate ground and unclassified points
\*(T< $ las2las --input in.las --output out.las --drop-classes 1 2 \*(T>
removes points that have a classification of 1 or 2.
Convert to 1.1
\*(T< $ las2las --input in.las --output out.las --format 1.1 \*(T>
converts the in.las file to a 1.1-formatted file. For the most part, this conversion is "in name only."
Alter vertical datum information
\*(T< $ las2las in.las --a_vertcs 5703 "North American Vertical Datum of 1988 (NAVD88)" 5103 9001 \*(T>
sets the vertical datum information for the file to be NAVD88 with vertical units of meters.
note. This may not be relevant depending upon the circumstances of the coordinate system the file is already in. This option only changes the *description* of the points. It does not reproject them in any way. Use a combination of \*(T<--a_srs\*(T> and \*(T<--t_srs\*(T> to do perform reprojection of the file.
File splitting
\*(T< $ las2las in.las --split-mb 10 \*(T>
splits the file into the required number of output-n.las files. Other filters or operations may also be applied to the operation in combination with splitting. Each outputted file will have its extents and point counts properly set.
\*(T< $ las2las in.las --split-pts 100000 \*(T>
splits the file into the required number of output-n.las files with 100000 points each in them. Other filters or operations may also be applied to the operation in combination with splitting. Each outputted file will have its extents and point counts properly set.
note. \*(T<--split-mb\*(T> and \*(T<--split-pts\*(T> will not work exactly with \*(T<--min-offset\*(T>. \*(T<--min-offset\*(T> will take the minimum offsets of the entire file, not each individual file that is a result of the split.
VLR addition
\*(T< $ las2las in.las --add-vlr CUSTOM_VLR 42 "A VLR description" "myfile.ext" \*(T>
adds a new VLR with name CUSTOM_VLR and an ID of 42. "myfile.ext" can either be a location to a file to read to write into the VLR, or properly escaped text that will be inserted directly into the VLR.
warning. VLRs have a size limitation of 65536 bytes. Files that are read or escaped arguments that are larger than 64k in size will cause an error to be thrown. Automatic truncation will not happen.
note. If you attempt to add VLRs with an ID of 34735, 34736, or 34737, your VLR will not be added. This is because libLAS expects to manage the GeoTIFF keys for you. You should use the SRS handling facilities if you need to set GeoTIFF keys instead of attempting to overwrite them directly.
VLR removal
\*(T< $ las2las in.las --delete-vlr CUSTOM_VLR 42 \*(T>
removes all VLRs from in.las when writing the new output.las file.
Adding color from an image
It is possible to use las2las to set RGB color information from an image and set it on the points. This requires a rewrite of the file and in some cases will require changing both the format and point-format of the file. The following example takes the \*(T<input.las\*(T> file, sets its format to \*(T<1.2\*(T>, and sets the point format to \*(T<3\*(T> so it can store color information. It also re-orders the color bands to have the 3rd band in the image be red, 1st band be green, and second band be blue. Additionally, the color values are then multiplied by the \*(T<--color-source-scale\*(T> factor or 256 to rescale the 8 bit image data to 16 bit color data.
\*(T< las2las -i input.las \ --color-source image.img \ -o output.las \ --file-format 1.2 \ --point-format 3 \ --color-source-scale 256 \ --color-source-bands 3 1 2 \*(T>
note. If the coordinate system of \*(T<image.img\*(T> is not the same as the input coordinate system of the LAS file, you should use GDAL VRTs to cause the image to be warped and reprojected as part of the read process. See for more detail.
warning. support must be enabled for this to work.