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

More open modes #17

Closed tmontaigu closed 3 years ago

tmontaigu commented 4 years ago

Right now the pylas.open function only alows to open in read mode. (Writing is possible but it is a method a pylas.LasBase class)

The PR #16 plan to add a Write mode to create a new file and write to it.

Can a "append" mode be added ?:

Can a read + write be added ?:

In both cases the hardest will be the compressed case (LAZ file) as well as files with EVLRs). (Append mode seems more feasible tho)

tmontaigu commented 3 years ago

Append mode implemented in #19

Read + Write mode cannot be done in a LAZ file without having complex code and poor performance because many read & write operations would be needed.

Example I want to overwrite from points at position 75_000 to 125_000 (so 50_000 points) Assuming laz is written in chunks with chunk size = 50_000 points per chunk (the default):

1) we would need to seek to the second chunk 2) read a = 25_000 points (points 50_000 to 75_000), keep them 3) read b = 25_000 points (points 125_000 to 150_000), keep them 4) seek back to start of second chunk 4) write (compressed) a + new points + b (= 100_00 points)

And the problem is that since we are compressing data, the result of the compression of the 100_000 points will either take less or more bytes which in both cases we would need to do a lot of work to handle properly and not corrupt the file and its not worth.

For LAS format r+w mode is possible easily but it's just easier to use pylas.LasMMAP