mreutegg / laszip4j

The LASzip library ported to Java
GNU Lesser General Public License v2.1
34 stars 15 forks source link

Can I use laszip4j to modify a lidar file content? #117

Open gwlucastrig opened 8 months ago

gwlucastrig commented 8 months ago

I have Java code that processes a lidar file and identifies anomalous sample points. I would like to be able to transcribe an existing file content, either removing the anomalous records or marking them as "withheld". I am also working on the ability to classify points.

Is there way to use laszip4j to handle the writing operations? If so, is there example code or documentation in the repository?

Ideally, I would like to be able to preserve header elements and other data such as VLR's so that I had a viable output file at the end of the process.

Thanks.

P.S. Sorry to have used a Github Issue to convey what is really just a question, but I didn't see any alternate means of contact.

mreutegg commented 8 months ago

Write capabilities of laszip4j are currently a bit limited. Re-classifying points is possible. See the following lines in LASWriterTest.

https://github.com/mreutegg/laszip4j/blob/98d8d821ca0c67ef0114af7555012632afdab805/src/test/java/com/github/mreutegg/laszip4j/LASWriterTest.java#L51-L59

You basically read points, transform them (e.g. change the classification of a point) and write them back to another file.

As you can see in https://github.com/mreutegg/laszip4j/blob/98d8d821ca0c67ef0114af7555012632afdab805/src/main/java/com/github/mreutegg/laszip4j/LASPointModifier.java it currently only allows setting the classification.

I added support for updating the withheld flag in https://github.com/mreutegg/laszip4j/pull/118

Would this work for you?

mreutegg commented 3 months ago

PR #118 is now merged and included in laszip4j 0.18. I'll keep this issue open, because laszip4j still does not have general support for modifying point data.