tmontaigu / pylas

⚠️ pylas was merged into laspy 2.0 https://github.com/laspy/laspy⚠️
BSD 3-Clause "New" or "Revised" License
39 stars 13 forks source link

Make `pylas.open` more pythonic #5

Closed mccarthyryanc closed 6 years ago

mccarthyryanc commented 6 years ago

This might be a tough request, but it would be nice to be able to separate out the current open function into more pythonic open and read functions. For example:

with pylas.open('simple.laz') as fh:
    fh.read()

Having pylas.open read into the file/handle/stream enough just to get the header, would also provide convenient/quick access to some info without reading the entire dataset.

tmontaigu commented 6 years ago

Well, I planned on renaming the open function as it's a terrible name for a function that actually reads the content.

As for the ability to have a open function that would then allow to read certain par of the file, it can be done I'm exploring a way to to it, but I don't know how well it's going to end.

tmontaigu commented 6 years ago

I just merged a branch that makes pylas.open more pythonic. pylas.open will now just read the header.

with pylas.open('simple.laz') as fh:
   print(fh.read_vlrs())
   if fh.header.number_of_point_records <10 ** 6:
       las = fh.read()

The old pylas.open (which was reading the whole file) is now named pylas.read

mccarthyryanc commented 6 years ago

Awesome! Thanks for the quick response on this! Constantly impressed with this module! Just a question about the if block: is there a hard coded limit on the number points to read it?

tmontaigu commented 6 years ago

No, the block is just a small example of what you could do