Swiss hillshading: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Created page with "http://mappractical.blogspot.com/2011/09/swiss-hillshade-model-in-arcmap.html <pre> # Import arcpy module import arcpy # Check out any necessary licenses arcpy.CheckOutExten..."
 
Brian Wilson (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
http://mappractical.blogspot.com/2011/09/swiss-hillshade-model-in-arcmap.html
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


<pre>
<pre>
# Import arcpy module
import arcpy
import arcpy


# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")
arcpy.CheckOutExtension("spatial")


# Set Geoprocessing environments
arcpy.env.scratchWorkspace = "C:\\Temp\\ScratchWorkspace"
arcpy.env.scratchWorkspace = "C:\\Temp\\ScratchWorkspace"
arcpy.env.workspace = "C:\\Temp"
arcpy.env.workspace = "C:\\Temp"
# Set up the parameters


Input_DEM = "C:\\Temp\\dem"
Input_DEM = "C:\\Temp\\dem"
Z_factor = "1"
Z_factor = "1"
Filtered_Hillshade = "c:\\Temp\\Filtered_Hshd"
Divide_By = "5"
Aerial_Perspective = "C:\\Temp\\Aerial_Persp"


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


# Process: Divide
# 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)
arcpy.gp.Divide_sa(Input_DEM, Divide_By, DEM_divided)


# Process: Hillshade
# 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)
arcpy.gp.HillShade_sa(Input_DEM, Standard_Hillshade, "315", "45", "NO_SHADOWS", Z_factor)


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


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


# We're done!
</pre>
</pre>

Latest revision as of 17:10, 28 March 2014

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!