visr / LasIO.jl

Julia package for reading and writing the LAS lidar format.
Other
22 stars 13 forks source link

LAZ support #5

Closed mkborregaard closed 6 years ago

mkborregaard commented 6 years ago

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!

visr commented 6 years ago

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 https://github.com/JuliaLang/julia/issues/22832 which is fixed on master.

mkborregaard commented 6 years ago

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

visr commented 6 years ago

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

mkborregaard commented 6 years ago

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

visr commented 6 years ago

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.

visr commented 6 years ago

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.

mkborregaard commented 6 years ago

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 :joy:) 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).

mkborregaard commented 6 years ago

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

visr commented 6 years ago

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

visr commented 6 years ago

Great, should now be fixed with a60c6ca034866ea09d976b920dbbd1c6599765e1, 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.

mkborregaard commented 6 years ago

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
visr commented 6 years ago

Ah I'll check tomorrow, only tried with the .las version of your file. Could you verify if your laszip is working well from the command line, with the same flags as in the julia cmd?

On Thu, Aug 17, 2017, 22:29 Michael Krabbe Borregaard < notifications@github.com> wrote:

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

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/visr/LasIO.jl/issues/5#issuecomment-323185315, or mute the thread https://github.com/notifications/unsubscribe-auth/AEQ8M9RMz2y_ID-kF9iqSrqE5ZBIzImdks5sZKK0gaJpZM4O548b .

mkborregaard commented 6 years ago

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.

visr commented 6 years ago

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

mkborregaard commented 6 years ago

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

mkborregaard commented 6 years ago

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

visr commented 6 years ago

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