I'm using the rasterstats zonal_stats function (pip installed), and running it on a .vrt file.
Everything runs perfectly in my Ipython notebook, but when I try to run it in my regular python environment I get the following error:
RasterStatsError: Cannot open '.../africa_merged.vrt' as GDAL raster
The error points to the following lines of the rasterstats source code:
rds = gdal.Open(raster, GA_ReadOnly)
if not rds:
raise RasterStatsError("Cannot open %r as GDAL raster" % raster)
However I when I run this outside of the rasterstats zonal_stats function, it can open the .vrt file, and doesn't throw an error.
Has anyone else had this problem?
UPDATE: this is happening with regular GeoTiff files as well. So the problem isn't because of the .vrt file type.
Some version info:
Python: sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)
Osgeo: osgeo.gdal.VersionInfo(): 1110000
...
? It's likely you just have the incorrect path.