lidar

Version, currently master branch1 version
  • master branchlatestFeb 26, 2017

github.com/jblindsay/lidar

A Crystal language library for reading and writing LiDAR data in LAS format

6 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  lidar:
    github: jblindsay/lidar
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
no constraint declared
License
MIT
Author
John Lindsay

Dependencies

This version declares no dependencies.

README

lidar

This is a small library for reading and writing LiDAR data in the widely used LAS file format. The library has been developed as an experiment to learn the Crystal programming language.

Installation

Add this to your application's shard.yml:

dependencies:
  lidar:
    github: jblindsay/lidar

Usage

require "lidar"

file_name = "path/to/file/test.las"

# Create a new LasFile instance for reading based on the file_name
lf = Lidar::LasFile.new file_name, "r"

# Print the meta data contained in the LAS header
puts("#{lf}")

# Now print the variable length records (VLRs)
if lf.header.number_of_vlrs > 0
  (0...lf.header.number_of_vlrs).each { |i|
    puts "VLR #{i + 1}:"
    puts("#{lf.vlr_data[i]}")
  }
end

# Print the first 10 points of the LAS data
(0...10).each do |i|
  puts("Point #{i + 1} #{lf.get_xyzi_data(i)}")
end

# Create a new LAS file to write data into
file_name2 = "path/to/file/test2.las"
lf2 = Lidar::LasFile.new file_name2, "w"

# Add the header
lf2.add_header(lf.header)

# Add the VLRs to the file
lf.vlr_data.each do |vlr|
  lf2.add_vlr(vlr)
end

# Add the point data to the file that lies within a specified area
north = 4363700.0
south = 4363200.0
east = 659400.0
west = 658900.0
(0...lf.header.number_of_points).each do |i|
  p = lf[i]
  if (west <= p.point.x <= east) && (south <= p.point.y <= north)
    lf2.add_point_record(lf[i])
  end
end

# Write the data
lf2.write

Contributing

  1. Fork it ( https://github.com/jblindsay/lidar/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • jblindsay John Lindsay - creator, maintainer