I’ve opened a GeoTiff with rasterio:
import rasterio
with rasterio.open('Africa.tif') as src:
transform = src.meta['transform']
array = src.read(1)
array([[203, 203, 203, ..., 0, 0, 0],
[203, 203, 203, ..., 0, 0, 0],
[203, 203, 203, ..., 0, 0, 0],
...,
[ 0, 0, 0, ..., 0, 0, 0],
[ 0, 0, 0, ..., 0, 0, 0],
[ 0, 0, 0, ..., 0, 0, 0]], dtype=uint8)
Then I want to open this array data in GDAL:
gdal.Open(array,GA_ReadOnly)
but I get the following error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-65-ac65027e8ea3> in <module>()
----> 1 gdal.Open(array,GA_ReadOnly)
RuntimeError: not a string
However, opening the original Tiff in GDAL works fine:
gdal.Open('Africa.tif')
<osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x152e91450> >
I’m following the computations here: http://nbviewer.ipython.org/github/perrygeo/python-raster-stats/blob/master/docs/notebooks/Integrating%20with%20GeoPandas%20and%20Numpy.ipynb
but I want to do some masking of the input array before running the zonal computations on it (otherwise it’s not necessary to open the image in rasterio at all).
Here is the link to the Tiff file I’m using, in case that’s the issue:
https://drive.google.com/file/d/0B7dNXVF349Jsbm5mQUt5c3JCSDA/view?usp=sharing