Swiss hillshading

From Wildsong
Jump to navigationJump to search

http://mappractical.blogspot.com/2011/09/swiss-hillshade-model-in-arcmap.html

ESRI models are great and all that but don't generally work and are hard to document... so I exported to Python

import arcpy

arcpy.CheckOutExtension("spatial")

arcpy.env.scratchWorkspace = "C:\\Temp\\ScratchWorkspace"
arcpy.env.workspace = "C:\\Temp"

# Set up the parameters

Input_DEM = "C:\\Temp\\dem"
Z_factor = "1"
Divide_By = "5"

# Temp outputs
Standard_Hillshade = "C:\\Temp\\ScratchWorkspace\\hillshade"
DEM_divided = "C:\\Temp\\ScratchWorkspace\\dem_divided"

# Final outputs
Filtered_Hillshade = "c:\\Temp\\Filtered_Hshd"
Aerial_Perspective = "C:\\Temp\\Aerial_Persp"

# Create a DEM that's 20% of the original
arcpy.gp.Divide_sa(Input_DEM, Divide_By, DEM_divided)

# PHASE 1: Create a standard hillshade to be used only as input to second phase
arcpy.gp.HillShade_sa(Input_DEM, Standard_Hillshade, "315", "45", "NO_SHADOWS", Z_factor)

# I think this knocks down detail (generalize)
arcpy.gp.FocalStatistics_sa(Standard_Hillshade, Filtered_Hillshade, "Rectangle 4 4 CELL", "MEDIAN", "DATA")

# Add the generalized DEM to the hillshade
arcpy.gp.Plus_sa(DEM_divided, Standard_Hillshade, Aerial_Perspective)

# We're done!