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

Suppress print messages from underlying lib #544

Open
TennisBowling opened this issue Jul 1, 2024 · 0 comments
Open

Suppress print messages from underlying lib #544

TennisBowling opened this issue Jul 1, 2024 · 0 comments

Comments

@TennisBowling
Copy link

Hey all, GDAL prints when there's an error
with this code:

fn get_elev(band: &RasterBand, transform: &[f64; 6], lat: &f64, lon: &f64) -> f64 {
    let col = ((lon - transform[0]) / transform[1]) as isize;
    let row = ((lat - transform[3]) / transform[5]) as isize;

    let buf = match band.read_as::<f64>(
        (col, row),
        (1, 1),
        (1, 1),
        Some(gdal::raster::ResampleAlg::CubicSpline),
    ) {
        Ok(buf) => buf,
        Err(_) => {
            return f32::MIN as f64;
        }
    };
    buf.data()[0]
}

the err handle of the match works well, but it seems the underlying gdal lib prints this

ERROR 5: ./elev.tif, band 1: Access window out of range in RasterIO().  Requested
(86761,28098) of size 1x1 on raster of 86412x54012.

Is there any way to turn off these messages apart from redirecting stderr? it seems the python version has something: https://gis.stackexchange.com/questions/73463/gdal-and-python-dont-print-gdal-error-messages

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

1 participant