Beruflich Dokumente
Kultur Dokumente
/user/local/bin/python
# ---------------------------------------------------------------------------
# best_route_guide.py
# Created on: 2018-12-26 22:08:21.00000
# (Created by: Gustavo Colmenares)
# Description:
# ---------------------------------------------------------------------------
# import modules
import arcpy
import os
from arcpy.sa import *
# Reclassify variables
slope = os.path.join(out_path, "Slope_out")
remap_slope = RemapRange([[0, 4.779894, 1],
[4.779894, 9.559789, 2],
[9.559789, 14.339683, 3],
[14.339683, 19.119577, 4],
[19.119577, 23.899471, 5],
[23.899471, 28.679366, 6],
[28.679366, 33.459260, 7],
[33.459260, 38.239154, 8],
[38.239154, 43.019048, 9],
[43.019048, 47.798943, 10]
])
# WeightedOverlay variables
landuse = "landuse"
weighted_remap_slope = RemapValue([[1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5],
[6, 6],
[7, 7],
[8, 8],
[9, 9],
[10, 10],
["NODATA", "NODATA"]
])
#-*-------------------*-------------
print(""" Starting process to find best route... """)
#
## Reclassification Process
out_reclass_slope = Reclassify(slope, "value", remap_slope)
out_reclass_slope.save(reclassed_slope)
print("reclass slope completed")
#
# Weighted Overlay process
"""
The WeightedOverlay() tool is returning message > Failed to execute. Parameters are not valid. ERROR 010531: The sum of % Influence Weights must equal
100.
to overcome to this error I decided to run the tool on Arc and use the resulting layer (Cost_Surface) in the script to continue...
"""
# WoTable
# try:
# myWOTable = WOTable([[reclassed_slope, 50, "VALUE", weighted_remap_slope],
# [landuse, 50, "VALUE", weighted_remap_landuse]],
# [eva_scl])
#
# print("myWOTable created")
# print(myWOTable)
# # Process: Weighted Overlay
# weighted_overlay = WeightedOverlay(myWOTable)
# weighted_overlay.save(cost_surface)
# except:
# print(arcpy.GetMessages())