Re: Silencing NotGeoreferencedWarning


Guillaume Lostis
 

Hi Sean,

Thanks for your answer.
I understand why you would want to keep this as a warning so that a user can act upon it if needed.

If I understand correctly, rasterio currently lacks the ability to georeference an image properly through its RPC/GCP, so you will keep the warning as is for now?
I'd be happy to contribute what I can, at my level, to help move forward on these topics.
On RPCs, @underchemist has a WIP open here: https://github.com/mapbox/rasterio/pull/1845
On GCPs, Vincent contributed a method to estimate a transform matrix here: https://github.com/mapbox/rasterio/pull/1749

On Thu, 23 Jan 2020 at 18:10, Sean Gillies via Groups.Io <sean=mapbox.com@groups.io> wrote:
Hi Guillaume,

Rasterio logs, mostly at DEBUG level, so that you can run programs and see what the state was before a failure. You don't see them unless you turn the warning level down to DEBUG. A program can't easily react to log messages, they go out to the environment and are inspected (or discarded) after the program terminates.

Rasterio warns in a few places instead of using logging because at these places a user may want their program to react to the warning and use different logic, retry, add missing georeferencing, fix the alpha band shadowing, or whatever. An exception would be too strong in the georeferencing case, I think. But we can, with a couple lines of code, turn any NotGeoreferencedWarning into an exception that can be handled appropriately.

Certainly rasterio is lagging in the RPC/GCP realm and we should think about not warning after we add the missing capabilities to the package.

On Thu, Jan 23, 2020 at 7:49 AM Guillaume Lostis <g.lostis@...> wrote:
Hi Vincent,

Option 1 with RPCs and GCPs would be perfect for my use case because all of the datasets I open have one of them.
But it would still leave warnings when you write a png or jpg with no georeference as you pointed out.

I have to admit I didn't know rasterio had logs... What's the rationale behind deciding what goes to logs, and what goes to stderr/warnings?

On Thu, 23 Jan 2020 at 15:40, <vincent.sarago@...> wrote:
Hi Guillaume,
thanks for raising this, it happens to me often too.

I'm thinking about multiple solutions:
- check if the file has other georeferenced information (like rpc or gpc) internally before raising this warning. 
- instead of raising a warning maybe a logging.info would be sufficent ? 

I also encounter this when saving file like png or jpg that don't have georeference which appears to me unnecessary. 

--
Sean Gillies

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