ArcPy水文分析(河网分级、流域、集水区)

来源:互联网 发布:自动扫描软件 编辑:程序博客网 时间:2024/05/01 06:39

ArcGIS水文分析步骤较多,难以记忆,这点不得不艳羡一下QGIS那个一键水文分析。
好在有model builder和ArcPy,最近刚好用到,写好脚本测试跑了一把,效果不错,做个记录。

其中使用的DEM数据是网上下载的aster那个,后面flowacc的自定义参数是90。

# -*- coding: utf-8 -*-# ---------------------------------------------------------------------------# hydro.py# Created on: 2016-12-06# Usage: hydrology analysis# Description: result include watershed, basin, stream(with order)# ---------------------------------------------------------------------------# Import arcpy moduleimport arcpyarcpy.env.overwriteOutput = Truefrom arcpy import envfrom arcpy.sa import *# Set workspacearcpy.env.workspace = "C:/test.gdb"# Input DEM ratser fileDEM = "AsterDEM"# Check SRSsr = arcpy.Describe(DEM).spatialReferenceprint "Spatial Reference System:" + sr.name# Check out any necessary licensesprint "Spatial Analyst Extension Available:"print arcpy.CheckOutExtension("spatial")# Processfill = Fill(DEM)flowdir = FlowDirection(fill, "NORMAL")flowacc = FlowAccumulation(flowdir, "", "FLOAT")streamrs = SetNull(flowacc, 1, "VALUE <= 90") # flowacc <=90 -> null, 90+ -> 1streamlink = StreamLink(streamrs, flowdir)watershedrs = Watershed(flowdir, streamlink, "VALUE")arcpy.RasterToPolygon_conversion(watershedrs, "watershed", "NO_SIMPLIFY", "VALUE") # watershed polygon savedstreamorder = StreamOrder(streamrs, flowdir, "STRAHLER")# Attention! this one goes wrong: stream = StreamToFeature(streamorder, flowdir, "SIMPLIFY")StreamToFeature(streamorder, flowdir, "stream", "SIMPLIFY") # stream polyline savedbasinrs = Basin(flowdir)arcpy.RasterToPolygon_conversion(basinrs, "basin", "NO_SIMPLIFY","VALUE") # basin polygon savedprint "All done, Check 'stream, basin, watershed' in Current Workspace."
0 0
原创粉丝点击