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

Adding an option to gdal_translate to preserve selected metadata domains (for example when changing data types) #10966

Open
chuck1987 opened this issue Oct 8, 2024 · 2 comments

Comments

@chuck1987
Copy link

What is the bug?

When I am translating a NITF file to NITF file I except the TRE information to be maintained.
It was noticed then anytime a run this translation I will lose my TRE information if I specify a -ot flag.

Even if I translate the NITF file to the same -ot of the original, the TRE information is still removed. If I specify no -ot flag the TRE information is maintained.

Steps to reproduce the issue

.\gdal_translate.exe .\input.ntf .\output.ntf -co IC=C8 -co JPEG2000_DRIVER=JP2OpenJPEG -ot Byte -> TRE information lost

.\gdal_translate.exe .\input.ntf .\out.ntf -co IC=C8 -co JPEG2000_DRIVER=JP2OpenJPEG -> TRE information maintained

Versions and provenance

Windows/Linux
GDAL 3.10

Additional context

No response

@rouault
Copy link
Member

rouault commented Oct 8, 2024

Changing the output data type might invalidate metadata.
When you just do direct NITF -> NITF without options (but driver creation options), the NITF driver is able to retrieve information directly from the source NITF dataset.
When you use -ot, gdal_translate uses internally a VRT dataset, and out of caution doesn't preserve metadata, but a few safe metadata domains. You must keep in mind that gdal_translate is a generic tool that has no particular knowledge of NITF specificities.
For your use case, for the time being, you'd better use the Python/C++ API and manually se the metadata
Perhaps gdal_translate could have a new switch where the user could specify which metadata domains to preserve or all

@rouault rouault changed the title NITF losing all its TRE information when specifying an output type (-ot) Adding an option to gdal_translate to preserve selected metadata domains (for example when changing data types) Oct 8, 2024
@chuck1987
Copy link
Author

chuck1987 commented Oct 8, 2024

I figured it had something to do with that, but yes the gdal_translate switch would be a nice addition.
Currently using the TRE creation options to pass in all the original TRE information to the gdal_translate call as a possible work around.

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

No branches or pull requests

2 participants