-
Notifications
You must be signed in to change notification settings - Fork 184
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
Write raw values bigger than 255 (Uint8), or: how to write Uint32, Float32 etc? #365
Comments
Hello, thank you for posting this important issue. It helps gauge community interest in different features. Unfortunately, it's a current limitation of the writer that it can only write Uint8 values. However, updating the code to support other data types is very achievable. Please let me know if you have the time to write a PR and I can provide some more background. Hope you have a nice rest of your day. |
Thanks Daniel for the quick response! |
Hey, great to hear. Here's a few links to the relevant parts: The main file that does the writing: https://github.com/geotiffjs/geotiff.js/blob/master/src/geotiffwriter.js. I tried to put all the writing functionality in one file to keep things modular (and separate from the reading functionality). It does however use globals.js and utils.js. This line is currently assuming uint8 data type, but will need to be dynamic depending on nbit value I assume: https://github.com/geotiffjs/geotiff.js/blob/master/src/geotiffwriter.js#L255. I think the other lines in encodeImage will have be refactored as well. Hopefully this helps a little, but it already seems like you have a good sense of it. Happy to answer any more questions or help with code review later on. Best of luck! |
@DanielJDufour Here is the PR that adds support for writing uint8, uint16, uint32 and float32: I also added tests for each new data type (which all pass) |
That's awesome! I'll try to review it as soon as I can. Thank you! |
@DanielJDufour Quick reminder, so this PR isn't forgotten... |
Here is a snippet of the code I am testing with:
Unfortunately this won't work because when inspecting the resulting tiff with
gdalinfo -stats test.tiff -mm
The values have been corrupted:
while the Minimum is correct, the Maximum is off (because it exceeds the Uint8 limit).
I tried to change my code by adding
to the metadata but this gives me the following issue when inspecting the result:
Notice that the Type has now changed from Byte to UInt32, but the data does not seem to have been encoded correctly.
Any pointers are very welcome!
The text was updated successfully, but these errors were encountered: