RuntimeError opening rasterio array in GDAL

المشرف العام

Administrator
طاقم الإدارة
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) in () ----> 1 gdal.Open(array,GA_ReadOnly) RuntimeError: not a string However, opening the original Tiff in GDAL works fine:

gdal.Open('Africa.tif') I'm following the computations here: http://nbviewer.ipython.org/github/...ks/Integrating with GeoPandas and Numpy.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

I couldn't even open the file 'slope.tif' that rasterstats are using in their example:

with rasterio.open('slope.tif') as src: transform = src.meta['transform'] array = src.read(1) array --------------------------------------------------------------------------- IOError Traceback (most recent call last) in () 1 input_value_raster = get_ndvi_dir()+'/ndvi/'+ndvi_file_name 2 import rasterio ----> 3 with rasterio.open('slope.tif') as src: 4 transform = src.meta['transform'] 5 array = src.read(1) /Library/Python/2.7/site-packages/rasterio/__init__.pyc in open(path, mode, driver, width, height, count, crs, transform, dtype, nodata, **kwargs) 115 raise ValueError( 116 "mode string must be one of 'r', 'r+', or 'w', not %s" % mode) --> 117 s.start() 118 return s 119 /Library/Python/2.7/site-packages/rasterio/_base.so in rasterio._base.DatasetReader.start (rasterio/_base.c:2245)() /Library/Python/2.7/site-packages/rasterio/_err.so in rasterio._err.GDALErrCtxManager.__exit__ (rasterio/_err.c:893)() IOError: `slope.tif' not recognised as a supported file format.

أكثر...
 
أعلى