Giter VIP home page Giter VIP logo

lidario's Introduction

lidario

Description

lidario is a simple library for reading and writing LiDAR files stored in LAS format. The library is written using the Go programing language. Use the build.py file to build/install the source code. The script can also be used to run the tests.

Example Usage

import "github.com/jblindsay/lidario"

func main() {
    // Reading a LAS file
    fileName := "testdata/sample.las"
    var lf *lidario.LasFile
    var err error
    lf, err = lidario.NewLasFile(fileName, "r")
    if err != nil {
        fmt.Println(err)
    }
    defer lf.Close()

    // Print the data contained in the LAS Header
    fmt.Printf("%v\n", lf.Header)

    // Print the VLR data
    fmt.Println("VLRs:")
    for _, vlr := range lf.VlrData {
        fmt.Println(vlr)
    }

    // Get the X,Y,Z data for a single point
    x, y, z, err := lf.GetXYZ(1000)
    fmt.Printf("Point %v: (%f, %f, %f) Error: %v\n", j, x, y, z, err)
	
    // Get an entire point, including all parts
    var p lidario.LasPointer
    p, err = lf.LasPoint(1000)
    if err != nil {
        fmt.Println(err)
        t.Fatal()
    }
    fmt.Println("Point format:", p.Format())

    // Read all the points
    oldProgress := -1
    progress := 0
    for i := 0; i < int(lf.Header.NumberPoints); i++ {
        if p, err := lf.LasPoint(i); err != nil {
            fmt.Println(err)
            t.Fatal()
        } else {
            if i < 10 {
                pd := p.PointData()
                fmt.Printf("Point %v: (%f, %f, %f, %v, %v, %f)\n", i, pd.X, pd.Y, pd.X, pd.Intensity, pd.ClassBitField.ClassificationString(), p.GpsTimeData())
            }
            progress = int(100.0 * float64(i) / float64(lf.Header.NumberPoints))
            if progress != oldProgress {
                oldProgress = progress
                if progress%10 == 0 {
                    fmt.Printf("Progress: %v\n", progress)
                }
            }
        }
    }

    // Create a new LAS file
    newFileName := "testdata/newFile.las"
    newLf, err := lidario.InitializeUsingFile(newFileName, lf)
    if err != nil {
        fmt.Println(err)
        t.Fail()
    }
    defer newLf.Close()

    progress = 0
    oldProgress = -1
    for i := 0; i < int(lf.Header.NumberPoints); i++ {
        if p, err := lf.LasPoint(i); err != nil {
            fmt.Println(err)
            t.Fatal()
        } else {
            if p.PointData().Z < 100.0 { // only output the point if the elevation is less than 100.0 m
                newLf.AddLasPoint(p)
            }
        }
        progress = int(100.0 * float64(i) / float64(lf.Header.NumberPoints))
        if progress != oldProgress {
            oldProgress = progress
            if progress%10 == 0 {
                fmt.Printf("Progress: %v\n", progress)
            }
        }
    }
}

lidario's People

Contributors

jblindsay avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.