利用ArcGIS结合DEM提取小流域单元

本文详细介绍了如何利用ArcGIS进行填洼分析、流向及流量计算、河网提取、河流链接、分水岭确定,最终将分水岭数据转换为小流域数据的全过程。
摘要由CSDN通过智能技术生成
DEM(数字高程模型)用于地理信息系统(GIS)中,提取流域特征通常涉及到流线追踪和区域划分。以下是一个简单的Python示例,使用GDAL库(Geospatial Data Abstraction Library)和FlowDirector模块来提取流域: ```python from osgeo import gdal, ogr, gdal_array import numpy as np # 读取DEM数据 dem_raster = gdal.Open("path_to_your_DEM.tif") band = dem_raster.GetRasterBand(1) dem_data = band.ReadAsArray() # 创建流网络 flow_dir = FlowDirectorSteepest(dem_data, -9999) # 将未指定方向设为-9999 (通常是海洋或者无效区域) flow_dir.run_one_step() # 提取流域 basins = flow_dir.reach_code catchments = basins.reshape((dem_data.shape[0], dem_data.shape[1])) # 计算流域面积 cell_size = dem_raster.GetGeoTransform()[1] # 获取栅格单元尺寸 areas = cell_size * cell_size * np.count_nonzero(catchments, axis=(0, 1)) # 输出流域特征(如最大流域、最小流域、平均流域面积) max_area_index = np.argmax(areas) min_area_index = np.argmin(areas) print(f"最大流域面积: {areas[max_area_index]} 平方米") print(f"最小流域面积: {areas[min_area_index]} 平方米") # 存储流域分块 ogr_driver = ogr.GetDriverByName('ESRI Shapefile') out_shp = ogr_driver.CreateDataSource('output.shp') out_layer = out_shp.CreateLayer('catchments', geom_type=ogr.wkbPolygon) field_defn = ogr.FieldDefn('Area', ogr.OFTReal) out_layer.CreateField(field_defn) for i, basin in enumerate(np.unique(catchments)): mask = catchments == basin polygon = ogr.Geometry(ogr.wkbPolygon) for ring in ogr.GeometryFromArray(mask).GetGeometryRef(0).ExportToWkt().split(";"): if "LINESTRING" not in ring: polygon.AddGeometryDirectly(ogr.CreateGeometryFromWkt(ring)) feature = ogr.Feature(out_layer.GetLayerDefn()) feature.SetField('Area', areas[i]) feature.SetGeometry(polygon) out_layer.CreateFeature(feature)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小咖~

码字不易,感谢您的打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值