arcgis学习笔记(2): 根据DEM提取河网


目录:

1. 利用 arcgis 的空间分析模块生成水网,然后人工在进行修饰

  • 需要修改的参数:

  • (1) 一个是DEM的文件名称(此脚本需要把 DEM 加载到视图中)

  • (2) 一个是累积流量,一般根据经验值或者测量的数据,即就是 streamrs 中VALUE 参数值得设定,值越大,得到的河网越密,反之则稀疏

# -*- coding: utf-8 -*-

# ---------------------------------------------------------------------------

# hydro.py

# Created on: 2016-12-06

# Usage: hydrology analysis

# Description: result include watershed, basin, stream(with order)

# ---------------------------------------------------------------------------

# Import arcpy module

import arcpy

arcpy.env.overwriteOutput = True

from arcpy import env

from arcpy.sa import *

# Set workspace

arcpy.env.workspace = "G:JLRiverJLRiverDemdem"

# Input DEM ratser file

DEM = "thailandl"

# Check SRS

sr = arcpy.Describe(DEM).spatialReference

print "Spatial Reference System:" + sr.name

# Check out any necessary licenses

print "Spatial Analyst Extension Available:"

print arcpy.CheckOutExtension("spatial")

# Process

fill = Fill(DEM)

flowdir = FlowDirection(fill, "NORMAL")

flowacc = FlowAccumulation(flowdir, "", "FLOAT")

streamrs = SetNull(flowacc, 1, "VALUE <= 900") # flowacc <=900 -> null, 900+ -> 1

streamlink = StreamLink(streamrs2, flowdir)

watershedrs = Watershed(flowdir, streamlink, "VALUE")

arcpy.RasterToPolygon_conversion(watershedrs, "watershed", "NO_SIMPLIFY", "VALUE") # watershed polygon saved

streamorder = StreamOrder(streamrs, flowdir, "STRAHLER")

# Attention! this one goes wrong: stream = StreamToFeature(streamorder, flowdir, "SIMPLIFY")

StreamToFeature(streamorder, flowdir, "stream", "SIMPLIFY") # stream polyline saved

basinrs = Basin(flowdir)

arcpy.RasterToPolygon_conversion(basinrs, "basin", "NO_SIMPLIFY","VALUE") # basin polygon saved

print "All done, Check 'stream, basin, watershed' in Current Workspace."