Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header update API? #304

Open
fabiopicchi opened this issue Jan 22, 2024 · 1 comment
Open

Header update API? #304

fabiopicchi opened this issue Jan 22, 2024 · 1 comment

Comments

@fabiopicchi
Copy link
Contributor

Is there an API to update the header of a laz file? Right now I am using the chunked writing pattern, however that is very slow since we have to decompress and recompress the data.

My current use case is that I need to patch wrong CRS information in the header.

@tmontaigu
Copy link
Member

It is the best way if you want to ensure that the file is correct (otherwise laspy has a bug)

The problem with what you want to achieve is that changing the VLR will likely change its length, which means we have the same problem as in #277

If the new length is greater, you would overwrite points by writing that new header/vlr, so the only option is to rewrite the whole file

If the new length is the same, then its ok

If the new length is smaller, you might be able to achieve what you want but that involves padding the header by setting the LasHeader.extra_header_bytes or extra_vlr_bytes so that the new length matches the old one

You can use LasHeader.read_from/write_to methods to do that. And write to temporary io.BytesIO to check the lengths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants