问题描述
我正在尝试在 jupyter notebook 中使用 Python 进行分水岭分析。每当我在 Python 中传递有关分水岭划分的命令时,我都会将输出作为栅格矩阵,而当我使用 imshow() 命令将其绘制在图形中时,我会在图形中获取平方图像而不是所需的输出。我正在传递命令,例如:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import geopandas as gpd
from pysheds.grid import Grid
import mplleaflet
%matplotlib inline
import tifffile as tif
grid = Grid.from_raster(r'D:\...\ASTGTMV003_N19E073_dem.tif',data_name='dem')
grid.view('dem')
输出:
Raster([[202.,204.,...,517.,524.,532.],[204.,202.,514.,519.,523.],[202.,201.,200.,516.,519.],[ 0.,0.,606.,604.],607.,603.],612.,610.]],dtype=float32)
...
然后在计算流域面积时:
流向:
grid.flowdir(data='inflated_dem',out_name='dir',dirmap=dirmap)
grid.view('dir')
输出:
Raster([[ 0.,0.],2.,-1.,4.,1.,64.,128.,0.]],dtype=float32)
但后来我使用以下方法将其绘制在图像中:
plotFigure(grid.dir,'Flow Direction','viridis')
我得到了图像,但是通过指定 x 和 y 计算集水区:
x,y = 73.6,19.6
grid.catchment(data='dir',x=x,y=y,dirmap=dirmap,out_name='catch',recursionlimit=15000,xytype='label')
grid.clip_to('catch')
catch = grid.view('catch')
plt.imshow(catch)
我在此处输入图像描述时得到输出
enter image description here
为什么会发生这种情况?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)