visr / LasIO.jl

Julia package for reading and writing the LAS lidar format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LAZ support

mkborregaard opened this issue · comments

Hi,
this looks like a great package - unfortunately all my data is in laz not las format. Are there any plans to incorporate laz format at some point, or should I go to things like laslib?
Thanks!

If you have laszip in your path it's possible to pipe your data through it to get laz support.
Can you try out the laszip branch, where this is added? Do note that if you are on 0.6.0 you may get hanging due to JuliaLang/julia#22832 which is fixed on master.

I have the laszip dll in my displaz folder - is that the one I should put in my PATH?

No sorry it's not the shared library but the executable that you need for this.

Oh, sorry, I'm on Mac. Downloading Laszip and running make in the laszip folder seems to only compile the dll.

It should work on Mac, but you have to get a laszip executable for Mac somewhere. Not sure what's best, it looks like it's on homebrew, or build it yourself. From www.laszip.org there seem to be only binaries for Windows available.

Hmm it seems supported but I never tried it before. Perhaps build LAStools instead? I know this does make a laszip executable, and seems to be more frequently updated.

OK, I checked the Homebrew install but that isn't working (doesn't build the executable). But I realized finally (from here: https://groups.google.com/forum/#!topic/lastools/7zzKK3678u0) that I could download all of LAStools, make, then manually direct my PATH to the bin folder, and I have it opening on your laszip branch. (EDIT: I just realize that's exactly what you told me to do above 😂)
I do get an error, though:

julia> using LasIO, FileIO
julia> points = load("PUNKTSKY_1km_6193_711.laz")
Error encountered while loading "PUNKTSKY_1km_6193_711.laz".
Fatal error:
ERROR: invalid Array dimensions
Stacktrace:
 [1] read(::Pipe, ::Int64) at ./io.jl:528
 [2] read(::Pipe, ::Type{LasIO.LasHeader}) at /Users/michael/.julia/v0.6/LasIO/src/header.jl:157
 [3] load(::Pipe) at /Users/michael/.julia/v0.6/LasIO/src/fileio.jl:28
 [4] open(::LasIO.##5#6, ::Cmd) at ./process.jl:601
 [5] load(::FileIO.File{FileIO.DataFormat{:LAZ}}) at /Users/michael/.julia/v0.6/LasIO/src/fileio.jl:41
 [6] eval(::Module, ::Any) at ./boot.jl:235
 [7] #load#20(::Array{Any,1}, ::Function, ::FileIO.File{FileIO.DataFormat{:LAZ}}) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:98
 [8] load(::FileIO.File{FileIO.DataFormat{:LAZ}}) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:86
 [9] #load#13(::Array{Any,1}, ::Function, ::String) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:52
 [10] load(::String) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:52

The input laz file is valid (opens in displaz).

Here's a google link to the laz file in case you want to try it out yourself: https://drive.google.com/open?id=0BwWjA0Ez4iLhOHp0eVRCaVp4X1k

Thanks, I see the same error, and your file passes lasvalidate. Will investigate.

Great, should now be fixed with a60c6ca, which is also added to the laszip branch.

This is a LAS 1.3 file, something I hadn't tried before, and it has an extra field in the header that we didn't read causing things to be misaligned.

Hm strange, I get

julia> using LasIO, FileIO
INFO: Recompiling stale cache file /Users/michael/.julia/lib/v0.6/LasIO.ji for module LasIO.

julia> header, points = load("PUNKTSKY_1km_6193_711.laz")
Error encountered while loading "PUNKTSKY_1km_6193_711.laz".
Fatal error:
ERROR: EOFError: read end of file
Stacktrace:
 [1] unsafe_read(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Ptr{UInt8}, ::UInt64) at ./iobuffer.jl:105
 [2] unsafe_read(::Base.PipeEndpoint, ::Ptr{UInt8}, ::UInt64) at ./stream.jl:752
 [3] unsafe_read(::Pipe, ::Base.RefValue{Float64}, ::Int64) at ./io.jl:361
 [4] read at ./io.jl:363 [inlined]
 [5] read at ./io.jl:367 [inlined]
 [6] read(::Pipe, ::Type{LasIO.LasPoint3}) at /Users/michael/.julia/v0.6/LasIO/src/point.jl:187
 [7] load(::Pipe) at /Users/michael/.julia/v0.6/LasIO/src/fileio.jl:34
 [8] open(::LasIO.##5#6, ::Cmd) at ./process.jl:601
 [9] load(::FileIO.File{FileIO.DataFormat{:LAZ}}) at /Users/michael/.julia/v0.6/LasIO/src/fileio.jl:41
 [10] eval(::Module, ::Any) at ./boot.jl:235
 [11] #load#20(::Array{Any,1}, ::Function, ::FileIO.File{FileIO.DataFormat{:LAZ}}) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:98
 [12] load(::FileIO.File{FileIO.DataFormat{:LAZ}}) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:86
 [13] #load#13(::Array{Any,1}, ::Function, ::String) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:52
 [14] load(::String) at /Users/michael/.julia/v0.6/FileIO/src/loadsave.jl:52

laszip PUNKTSKY_1km_6193_711.laz appears to work, and puts a las file in the directory. But julia> using LasIO, FileIO; header, points = load("PUNKTSKY_1km_6193_711.las") generates the same error as above.

Ok thanks for checking, I added a21bf46 now, that should fix it. Let me know how it works for you.

Yup, it works great now, thanks a lot for this! Should I close the issue?

Also, I am on julia 0.6 and experienced no hanging. The loading was very quick.

Great. Let's leave it open for now, such that others can find it until we merge this into master.