Re: Silencing NotGeoreferencedWarning


Sean Gillies
 

Hi Nikos,

On Thu, Oct 29, 2020 at 4:29 PM Nikos Alexandris <nik@...> wrote:
Thank you for this. It's been bugging for quite some time.
I use it here: https://gitlab.com/thermopolis/public/ecor/-/blob/master/ecor/utilities.py.

I have the same question, as this snippet need to appear in every function that `rasterio.open()`s a HDF5 (sub)dataset:
is there a more elegant way to silence this warning?

Cheers

(data) vas-y:~ seang$ python -W "ignore:Dataset has no geotransform set" -c "import rasterio; rasterio.open('/Users/seang/Desktop/DSC_1549.jpg')"
(data) vas-y:~ seang$ python -c "import rasterio; rasterio.open('/Users/seang/Desktop/DSC_1549.jpg')"
/Users/seang/envs/data/lib/python3.6/site-packages/rasterio/__init__.py:218: NotGeoreferencedWarning: Dataset has no geotransform set. The identity matrix may be returned.
  s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
 
We're going to support RPCs in 1.2.0, so you'll see less of this warning, but in the meanwhile I can't suggest anything other than explicitly silencing warnings when you open a file using a context manager or changing Python's filter before you run a program like this:

$ python -W "ignore:Dataset has no geotransform set" -c "import rasterio; rasterio.open('/Users/seang/Desktop/DSC_1549.jpg')"

No warnings! Without -W you will get them.

$ python -c "import rasterio; rasterio.open('/Users/seang/Desktop/DSC_1549.jpg')"
/Users/seang/envs/data/lib/python3.6/site-packages/rasterio/__init__.py:218: NotGeoreferencedWarning: Dataset has no geotransform set. The identity matrix may be returned.
  s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
 
--
Sean Gillies

Join main@rasterio.groups.io to automatically receive all group messages.