如何解决使用 Python 进行流域分析
我正在尝试在 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 举报,一经查实,本站将立刻删除。