add_coastlines.sh: cannot identify input image file

Post Reply
rrabin
Posts: 17
Joined: Tue Sep 13, 2022 9:14 pm

add_coastlines.sh: cannot identify input image file

Post by rrabin »

Hello,

I get the following error when executing the command:

add_coastlines.sh output3.tif --add-coastlines --add-borders --borders-resolution=h --add-grid --grid-D 1.0 1.0
PIL.UnidentifiedImageError: cannot identify image file 'output3.tif'

The file output3.tif was created with the following command:
rio warp image.tif -o output3.tif --bounds -80 29 -60 49 --res 0.02 –dst-crs ‘+proj=longlat +ellps=WGS84’

image.tif was created from geo2grid.sh

I have placed image.tif, output3.tif in ftp://pub/incoming

Thanks! -Bob
davidh
Posts: 115
Joined: Tue Jun 04, 2013 11:19 am

Re: add_coastlines.sh: cannot identify input image file

Post by davidh »

Hi Bob,

If you run the output tif through gdalinfo you'll see this at the bottom:

Band 1 Block=256x256 Type=Byte, ColorInterp=Gray
Band 2 Block=256x256 Type=Byte, ColorInterp=Undefined

It seems like rasterio (rio) is losing the alpha definition of the second band for some reason. I would consider this a bug that you should file with rasterio. My guess is it will happen with any LA (Luminance Alpha) geotiff being processed with GDAL warp. That said, a quick fix is to add:

Code: Select all

--co ALPHA=YES
Let me know how it goes.

Dave
rrabin
Posts: 17
Joined: Tue Sep 13, 2022 9:14 pm

Re: add_coastlines.sh: cannot identify input image file

Post by rrabin »

Hi Dave,

Thank you! The quick fix works! I'll report the bug to rastario.

Best wishes,
-Bob
rrabin
Posts: 17
Joined: Tue Sep 13, 2022 9:14 pm

Re: add_coastlines.sh: cannot identify input image file

Post by rrabin »

Hi Dave,

I updated the Python environment to 3.8 (from 3.7). The error doesn't occur with version 3.8.

Thanks!

-Bob
rrabin
Posts: 17
Joined: Tue Sep 13, 2022 9:14 pm

Re: add_coastlines.sh: cannot identify input image file

Post by rrabin »

Correction: the error still occurs with version 3.8
davidh
Posts: 115
Joined: Tue Jun 04, 2013 11:19 am

Re: add_coastlines.sh: cannot identify input image file

Post by davidh »

Bob,

The bug is not in Python or in Polar2Grid/Geo2Grid, it is specifically in the rasterio python package or the GDAL C++ library that rasterio uses underneath. You can see what version of rasterio is available here:

https://pypi.org/project/rasterio/

But know that I was using the latest version when I tested your example and got the same result so it is not a bug that is fixed. If you'd like to file a bug report for the rasterio project then you can do so here:

https://github.com/rasterio/rasterio/issues

You may want to search through the existing issues to see if someone else has run into the same issue.

Dave
Post Reply