I would like to set value of raster -999.0 as NaN in crop_image function, while reading/cropping file:

for band_path in range_bands:
    # open raster as numpy array by rater.io in content manager(open/close file)
    with rio.open(band_path) as band_src:
        if "band4" in band_path:
            ## use crop.image() to read and crop
            band4, band4_meta = es.crop_image(band_src, bound)
            # Update with NaN data values
            band4_meta.update({'nodata': -999.0})

How is possible to do?

  • Add a tag showing which python library you are using
    – BERA
    Mar 6, 2020 at 7:23
  • You can try to use a numpy mask, if the operation is done by numpy. Mar 6, 2020 at 18:46


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.