Class LasUtils


  • public class LasUtils
    extends Object
    Utilities for Las handling classes.
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Constructor Detail

      • LasUtils

        public LasUtils()
    • Method Detail

      • getLasFileVersion

        public static String getLasFileVersion​(File lasFile)
                                        throws IOException
        Read just the version bytes from a las file.

        This can be handy is one needs to choose version reader.

        Parameters:
        lasFile - the las file to check.
        Returns:
        the version string as "major.minor" .
        Throws:
        IOException
      • getLasFeatureBuilder

        public static org.geotools.feature.simple.SimpleFeatureBuilder getLasFeatureBuilder​(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
        Creates a builder for las data. The attributes are:
        • the_geom: a point geometry
        • elev
        • intensity
        • classification
        • impulse
        • numimpulse
        Parameters:
        crs - the CoordinateReferenceSystem.
        Returns:
        the builder.
      • tofeature

        public static org.opengis.feature.simple.SimpleFeature tofeature​(LasRecord r,
                                                                         Integer featureId,
                                                                         org.opengis.referencing.crs.CoordinateReferenceSystem crs)
        Convert a record to a feature.
        Parameters:
        r - the record to convert.
        featureId - an optional feature id, if not available, the id is set to -1.
        crs - the crs to apply.
        Returns:
        the feature.
      • toGeometry

        public static org.locationtech.jts.geom.Point toGeometry​(LasRecord r)
      • getLasRecordsFromFeatureCollection

        public static List<LasRecord> getLasRecordsFromFeatureCollection​(org.geotools.data.simple.SimpleFeatureCollection lasCollection,
                                                                         boolean elevIsGround)
        Create a LasRecord from a collection.

        The collection has to be created with the methods of this class previously, else some fields will be missing.

        Parameters:
        lasCollection - the collection to convert.
        elevIsGround - if true, the elevation is the ground height.
        Returns:
        the list of las records.
      • adjustedStandardGpsTime2DateTime

        public static org.joda.time.DateTime adjustedStandardGpsTime2DateTime​(double adjustedStandardGpsTime)
        Converts las adjusted standard gps time to DateTime.
        Parameters:
        adjustedStandardGpsTime - the time value.
        Returns:
        the UTC date object.
      • dateTimeToStandardGpsTime

        public static double dateTimeToStandardGpsTime​(org.joda.time.DateTime dateTime)
        Converts an date object to standard gps time.
        Parameters:
        dateTime - the object (UTC).
        Returns:
        the standard gps time in seconds.
      • dumpLasFolderOverview

        public static void dumpLasFolderOverview​(String folder,
                                                 org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                                          throws Exception
        Dump an overview shapefile for a las folder.
        Parameters:
        folder - the folder.
        crs - the crs to use.
        Throws:
        Exception
      • distance

        public static double distance​(LasRecord r1,
                                      LasRecord r2)
        Projected distance between two points.
        Parameters:
        r1 - the first point.
        r2 - the second point.
        Returns:
        the 2D distance.
      • distance3D

        public static double distance3D​(LasRecord r1,
                                        LasRecord r2)
        Distance between two points.
        Parameters:
        r1 - the first point.
        r2 - the second point.
        Returns:
        the 3D distance.
      • lasRecordToString

        public static String lasRecordToString​(LasRecord dot)
        String representation for a LasRecord.
        Parameters:
        dot - the record to convert.
        Returns:
        the string.
      • lasRecordEqual

        public static boolean lasRecordEqual​(LasRecord dot1,
                                             LasRecord dot2)
        Compare two LasRecords.
        Parameters:
        dot1 - the first record.
        dot2 - the second record.
        Returns:
        true, if the records are the same.
      • avg

        public static double avg​(List<LasRecord> points,
                                 LasUtils.VALUETYPE valueType)
        Calculate the avg of a value in a list of LasRecords.
        Parameters:
        points - the records.
        valueType - the value to consider.
        Returns:
        the avg.
      • histogram

        public static double[][] histogram​(List<LasRecord> points,
                                           LasUtils.VALUETYPE valueType,
                                           int bins)
        Calculate the histogram of a list of LasRecords.
        Parameters:
        points - the list of points.
        valueType - the value to consider.
        bins - the number of bins.
        Returns:
        the histogram as matrix of rows num like bins and 3 columns for [binCenter, count, cummulated-normalize-count].
      • triangulate

        public static List<org.locationtech.jts.geom.Geometry> triangulate​(List<LasRecord> lasPoints,
                                                                           Double elevThres,
                                                                           boolean useGround,
                                                                           IHMProgressMonitor pm)
        Triangulates a set of las points.

        If a threshold is supplied, a true dsm filtering is also applied.

        Parameters:
        lasPoints - the list of points.
        elevThres - the optional threshold for true dsm calculation.
        useGround - use the ground elevation instead of z.
        pm - the monitor.
        Returns:
        the list of triangles.
      • smoothIDW

        public static void smoothIDW​(List<LasRecord> lasPoints,
                                     boolean useGround,
                                     double idwBuffer,
                                     IHMProgressMonitor pm)
        Smooths a set of las points through the IDW method.

        Note that the values in the original data are changed.

        Parameters:
        lasPoints - the list of points to smooth.
        useGround - if true, the ground elev is smoothed instead of the z.
        idwBuffer - the buffer around the points to consider for smoothing.
        pm - the monitor.
      • getLastVisiblePointData

        public static double[] getLastVisiblePointData​(LasRecord baseRecord,
                                                       List<LasRecord> lasRecords,
                                                       boolean useGround)
        Return last visible point data for a las records points list from a given position.

        For the profile the min and max angles of "sight" are calculated. The min azimuth angle represents the "upper" line of sight, as thought from the zenith.

        The max azimuth angle represents the "below the earth" line of sight (think of a viewer looking in direction nadir).

        The return values are in an array of doubles containing:

        • [0] min point elev,
        • [1] min point x,
        • [2] min point y,
        • [3] min point progressive,
        • [4] min point azimuth,
        • [5] max point elev,
        • [6] max point x,
        • [7] max point y,
        • [8] max point progressive,
        • [9] max point azimuth
        Parameters:
        baseRecord - the record to use as center point.
        lasRecords - the LasRecord points sorted by nearest from the center dot.
        useGround - if true, use the ground info instead of z elevation.
        Returns:
        the last visible point parameters.
      • clone

        public static LasRecord clone​(LasRecord lasRecord)
        Clone a LasRecord.
        Parameters:
        lasRecord - the record to clone.
        Returns:
        the duplicate new object.