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

Feature request: implement scaleclip switch in gdal_transform #1825

Open
aloboa opened this issue Sep 9, 2019 · 3 comments
Open

Feature request: implement scaleclip switch in gdal_transform #1825

aloboa opened this issue Sep 9, 2019 · 3 comments

Comments

@aloboa
Copy link

aloboa commented Sep 9, 2019

I think it would be useful having -scale complemented by a parameter scaleclip to indicate "Clip output values to the effective range dst_min to dst_max defined in -scale"

@dselivanov
Copy link

I would like to work on this. @rouault could you please point where scale is calculated? (I'm new to GDAL source base).

@rouault
Copy link
Member

rouault commented Feb 19, 2022

@rouault could you please point where scale is calculated?

maybe surprisingly, this will not be a completely trivial change. The scaling is actually performed by the GDAL VRT driver.
gdal_translate pass the (offset, scale) pair at

poSource->SetLinearScaling(dfOffset, dfScale);
(they're computed a few lines before from src_min src_max dst_min dst_max at
dfScale = (dfScaleDstMax - dfScaleDstMin)
)
and the scaling computation in the VRT driver is done at
fResult = static_cast<WorkingDT>(
.
For a -scaleclip option to work, you'll have to modify the VRT serialization/deserialization from/to XML to store the src_min src_max dst_min dst_max parameters (this is already done for the exponential scaling, so that should be reused. you'll find that in the vrtsources.cpp file), as well as the option to clip.

@init931
Copy link

init931 commented Dec 21, 2023

Any updates on implementing this feature?

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

4 participants