Giter VIP home page Giter VIP logo

Comments (1)

Ellon avatar Ellon commented on July 20, 2024

Late reply, may still be useful.

(Disclaimer: I'm no laspy expert. I started using it few days ago).

If I understood properly, the values stored into EXTRA BYTES are decoded from the VLR and made accessible through their name. For instance, an extra bytes value with name "Amplitude" would be available through inFile.amplitude.

To the extent of my current knowledge, I don't know if there is a easy way print the name of the extra bytes you have. What you can do is to find the VLR containing the extra bytes and look for names in VLR_body. For example, in the output generated by the following code:

>>> for (i, vlr) in enumerate(inFile.header.vlrs):
...     print i, vlr.user_id, vlr.record_id
... 
0 LASF_Projection 34735
1 LASF_Projection 34736
2 LASF_Projection 34737
3 LASF_Projection 2112
4 LASF_Spec 4

you're looking for the line with LASF_Spec 4, since this is the combination of User Id and Record Id that define the extra bytes VLR. In this example it is located at the VLR with index 4. Then you can do:

>>> extra_bytes_vlr = inFile.header.vlrs[4]
>>> extra_bytes_vlr.VLR_body

to visualize the whole extra bytes VLR body. You may get something like:

"\x00\x00\x03\x0eAmplitude\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x00\x10'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00{\x14\xaeG\xe1z\x84?\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Echo signal amplitude [dB
]\x00\x00\x00\x00\x00\x00\x00\x00\x04\x0eReflectance\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x00x\xec\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x98:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{\x14\xaeG\xe1z\x84?\x00\x00\x00\x
00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Echo signa
l reflectance [dB]\x00\x00\x00\x00\x00\x00\x03\x07Deviation\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00Pulse shape deviation\x00\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00"

where you should look for the value names like the ones in bold. The other text is the extra byte value description. Names come before descriptions, and normally it should be clear what which one is what. You can access the extra bytes values using the names, in lower case, without \x00s and with spaces replaced by _s (this name transformation is done by laspy.header.VLR.add_extra_dim). In this example, it would be:

>>> inFile.amplitude
array([ 445,  146,  968, ...,  992, 1007,  942], dtype=uint16)
>>> inFile.reflectance
array([-1268, -1567,  -856, ...,  -593,  -578,  -642], dtype=int16)
>>> inFile.deviation
array([ 8,  0,  3, ..., 43, 54, 41], dtype=uint16)

Anyway, this depends on the names given for your extra bytes values. If they're not set or properly parsed by laspy then I don't know how to access them. Maybe a developer/maintainer can tell you an easier way to access the values and value names.

I hope this helps!

from laspy.

Related Issues (20)

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.