Silencing NotGeoreferencedWarning

Guillaume Lostis


I'm frequently working with GeoTIFF datasets that don't have a geotransform because they are georeferenced through other means (Sentinel-1 SLC images through the satellite state vectors, or non-orthorectified optical imagery through RPCs). Whenever I open such a dataset with rasterio, I get a warning:

NotGeoreferencedWarning: Dataset has no geotransform set. The identity matrix may be returned.

This warning is not useful to me as it is raised on every file I open, so I was looking for a way to silence it systematically. I've found that by doing:

import warnings
import rasterio
warnings.filterwarnings("ignore", category=rasterio.errors.NotGeoreferencedWarning)

it silences most warnings, but sometimes some of them get through the filter in for loops for example, or in the context of pytest. And it also has the disadvantage of having to show up everywhere in my code.

Is there a more radical way to always silence this warning?


Guillaume Lostis

Join to automatically receive all group messages.