Skip to content
This repository has been archived by the owner on Jan 6, 2019. It is now read-only.

Commit

Permalink
arcgis provider major clean-up (work in progress), see #23 #24
Browse files Browse the repository at this point in the history
  • Loading branch information
landam committed Nov 19, 2018
1 parent e9590c3 commit b405476
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 228 deletions.
24 changes: 13 additions & 11 deletions smoderp2d/providers/arcgis/arcgis_dmtfce.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import arcpy
import arcgisscripting
gp = arcgisscripting.create()
import sys
import os

def dmtfce(dmt, save_dir, fl_dir=None):
"""
def dmtfce(dmt, save_dir, fl_dir):
:param str dmt: DMT raster name
:param str save_dir: directory where to save output
:param str fl_dir: flow direction raster name or None
"""
# loading file soil_type_values
# filling the sink areas in raster
try:
dmt_fill = arcpy.sa.Fill(dmt)
except:
# TODO: use our own exceptions...
arcpy.AddMessage(
"Unexpected error during raster fill calculation:",
sys.exc_info()[0])
raise

# flow direction calculation
try: # tady by pak meslo jit pridavat pripraven fl dir
if fl_dir == "NONE":
try:
if not fl_dir:
flow_direction = arcpy.sa.FlowDirection(dmt_fill)
flow_direction.save(save_dir + os.sep + "fl_dir")
flow_direction.save(os.path.join(save_dir, "fl_dir")
else:
flow_direction = fl_dir

except:
arcpy.AddMessage(
"Unexpected error during flow direction calculation:",
Expand All @@ -33,8 +36,7 @@ def dmtfce(dmt, save_dir, fl_dir):
# flow accumulation calculation
try:
flow_accumulation = arcpy.sa.FlowAccumulation(flow_direction)
flow_accumulation.save(save_dir + os.sep + "facc")
# mat_fa = arcpy.RasterToNumPyArray(flow_accumulation)
flow_accumulation.save(os.path.join(save_dir, "facc"))
except:
arcpy.AddMessage(
"Unexpected error during flow accumulation calculation:",
Expand All @@ -44,11 +46,11 @@ def dmtfce(dmt, save_dir, fl_dir):
# slope calculation
try:
slope = arcpy.sa.Slope(dmt, "PERCENT_RISE", 1)
# ExtractByMask (slope, raster_dmt)
slope.save(save_dir + "\\slope")
slope.save(os.path.join(save_dir, "slope"))
except:
arcpy.AddMessage(
"Unexpected error during slope calculation:",
sys.exc_info()[0])
raise

return dmt_fill, flow_direction, flow_accumulation, slope
Loading

0 comments on commit b405476

Please sign in to comment.