6

I have the following script using rasterio:

if not os.path.isfile(out_dir + os.sep + name_adm1 + '.tif'):
    with rasterio.drivers():
        with rasterio.open(constants.ras_cmask) as src:
            b1 = src.read(1)

            profile = src.profile
            profile.update(
                dtype=rasterio.float64,
                count=1,
                compress='lzw')

        ndvi = b1.astype(float)
        ndvi[ndvi != int(num_ID)] = np.nan

        with rasterio.open(out_dir + os.sep + name_adm1 + '.tif', 'w', **profile) as dst:
            dst.write(ndvi.astype(rasterio.float64), 1)

However, when I run it, it produces a lot of messages like this:

03/13/2016 13:40:22  rasterio           DEBUG        Creating a not-responsible GDALEnv in drivers()
03/13/2016 13:40:22  rasterio           DEBUG        Got coordinate system
03/13/2016 13:40:22  rasterio           DEBUG        Got coordinate system
03/13/2016 13:40:22  rasterio           DEBUG        Input CRS: {'init': u'epsg:4326'}
03/13/2016 13:40:22  rasterio           DEBUG        Exported WKT: GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]
03/13/2016 13:40:22  rasterio           DEBUG        Self CRS: {'init': u'epsg:4326'}
03/13/2016 13:40:22  rasterio           DEBUG        Got coordinate system
03/13/2016 13:40:22  rasterio           DEBUG        Got coordinate system
03/13/2016 13:40:23  rasterio           DEBUG        Option: ('BLOCKYSIZE', '1')

03/13/2016 13:40:23  rasterio           DEBUG        Option: ('COMPRESS', 'LZW')

03/13/2016 13:40:23  rasterio           DEBUG        Option: ('BLOCKXSIZE', '7200')

03/13/2016 13:40:23  rasterio           DEBUG        Option: ('TILED', 'FALSE')

Warning 6: driver ENVI does not support creation option BLOCKYSIZE
Warning 6: driver ENVI does not support creation option COMPRESS
Warning 6: driver ENVI does not support creation option BLOCKXSIZE
Warning 6: driver ENVI does not support creation option TILED
Warning 6: driver ENVI does not support creation option BLOCKYSIZE
Warning 6: driver ENVI does not support creation option COMPRESS
Warning 6: driver ENVI does not support creation option BLOCKXSIZE

Is there a way to either suppress these, or redirect to logging file?

3
  • Which version of rasterio are you using ?
    – gene
    Mar 13, 2016 at 18:43
  • Upgrade! 0.25 is pretty old.
    – sgillies
    Mar 14, 2016 at 3:23
  • thanks @sgillies, I am having issues upgrading to 0.30, the pip install rolls back to 0.25
    – user1186
    Mar 14, 2016 at 16:51

1 Answer 1

7

Try adding this to your script:

from rasterio import logging

log = logging.getLogger()
log.setLevel(logging.ERROR)

You can substitute ERROR with other levels: DEBUG, INFO, WARN, FATAL.

3
  • 1
    thanks @bosth, this does help some, I am at logging.ERROR level, but can still see 'Warning`s
    – user1186
    Mar 13, 2016 at 18:47
  • Python's default log level is WARNING, so you shouldn't be seeing those DEBUG level messages except by the choices made by your environment. Are you using a Jupyter/IPython notebook?
    – sgillies
    Mar 14, 2016 at 3:26
  • thanks @sgillies, I just noticed your reply. I am not using any notebook, just straight up scripts.
    – user1186
    Mar 24, 2016 at 19:01

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.