Python 从zonal_统计数据中,我得到以下错误:ValueError:宽度和高度必须为>;0
我正在使用Rasterstats库中的zonal_stats函数。我已经在降水数据上使用了这个函数,它工作得无可挑剔。但是,当我尝试使用相同的向量,但使用不同的光栅数据集(用于实际蒸散量)运行函数时,我得到错误消息:Python 从zonal_统计数据中,我得到以下错误:ValueError:宽度和高度必须为>;0,python,raster,gdal,Python,Raster,Gdal,我正在使用Rasterstats库中的zonal_stats函数。我已经在降水数据上使用了这个函数,它工作得无可挑剔。但是,当我尝试使用相同的向量,但使用不同的光栅数据集(用于实际蒸散量)运行函数时,我得到错误消息: Traceback (most recent call last): File "<input>", line 3, in <module> File "/Users/ida/opt/anaconda3/envs/thesis_env/lib
Traceback (most recent call last):
File "<input>", line 3, in <module>
File "/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterstats/main.py", line 31, in zonal_stats
return list(gen_zonal_stats(*args, **kwargs))
File "/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterstats/main.py", line 159, in gen_zonal_stats
rv_array = rasterize_geom(geom, like=fsrc, all_touched=all_touched)
File "/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterstats/utils.py", line 47, in rasterize_geom
all_touched=all_touched)
File "/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterio/env.py", line 386, in wrapper
return f(*args, **kwds)
File "/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterio/features.py", line 347, in rasterize
raise ValueError("width and height must be > 0")
我已经在Qgis中打开了AET光栅文件,这里没有问题,投影看起来很好,数据范围也很好,而且它也与矢量形状文件重叠。我可以使用“分区统计”在Qgis中进行计算,但我需要对一组光栅数据进行相同的计算,因此使用Qgis一次一个地运行所有数据太耗时了
我可以用GDAL打开AET数据,它看起来是这样的,没有任何问题:
AET_raster = gdal.Open(filepath)
我以为是文件大小的问题,但这看起来也不错。
光栅的字符串如下所示
<osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x119250810> >
这些尺寸与我用于降水的光栅文件的尺寸相同
有人知道这里会出什么问题吗 请显示完整的异常回溯。感谢您的评论,我现在编辑了我的答案,因此包含了整个回溯。请显示完整的异常回溯。感谢您的评论,我现在编辑了我的答案,因此包含了整个回溯。
<osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x119250810> >
RasterCount = {int} 1, RasterXSize = {int} 1115, RasterYSize = {int} 834