Resampling raster error message: ValueError: Invalid source

Eyal Saiet
 

I am testing the Resamling code from the documentation-link, to resample a tiff file:
#resampling a raster
import rasterio
from rasterio.warp import Affine, Resampling, reproject
import numpy as np
src=rasterio.open(r'/home/esaiet/Documents/18_12_thesis_work/data/Aialik_glacier_bay.tif')
src_np=src.read()
newarr = np.empty(shape=(src_np.shape[0],round(src_np.shape[1] * 0.5), round(src_np.shape[2] * 0.5)))

aff = src.transform
newaff = Affine(aff.a / 0.5, aff.b, aff.c,aff.d, aff.e / 0.5, aff.f)

reproject(src, newarr,src_transform = aff,dst_transform = newaff,src_crs = src.crs,dst_crs = src.crs,resampling = Resampling.bilinear)
src.close()
But I am getting an error (ValueError: Invalid Source), I don't think it is the raster. Googling around did not find aynting. Perhaps the UTM projection is the problem!?
If the error was Invalid Source Image, then I would suspect a problem with the data source, but that does not seem to be the case.  I saw some post perhaps it is the "nodata" definition the probelm!? Thanks
--------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-31-cb98e54d177e> in <module>()
     12 
     13 reproject(src, newarr,src_transform = aff,dst_transform = newaff,src_crs = src.crs,dst_crs = src.crs,
---> 14     resampling = Resampling.bilinear)

/usr/local/lib/python3.6/dist-packages/rasterio/env.py in wrapper(*args, **kwds)
    371         else:
    372             with Env.from_defaults():
--> 373                 return f(*args, **kwds)
    374     return wrapper
    375 

/usr/local/lib/python3.6/dist-packages/rasterio/env.py in wrapper(*args, **kwds)
    594                                 param, full_kwds[param], inequality, version, reason))
    595 
--> 596             return f(*args, **kwds)
    597 
    598         return wrapper

/usr/local/lib/python3.6/dist-packages/rasterio/warp.py in reproject(source, destination, src_transform, gcps, src_crs, src_nodata, dst_transform, dst_crs, dst_nodata, src_alpha, dst_alpha, resampling, num_threads, init_dest_nodata, warp_mem_limit, **kwargs)
    295         src_alpha=src_alpha, resampling=resampling,
    296         init_dest_nodata=init_dest_nodata, num_threads=num_threads,
--> 297         warp_mem_limit=warp_mem_limit, **kwargs)
    298 
    299 

rasterio/_warp.pyx in rasterio._warp._reproject()

ValueError: Invalid source

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