How to save output raster and automatically open in ArcMap?

by JCB   Last Updated April 15, 2019 23:22 PM

I'm Python beginner. I want to reclass (by Table) raster files, then perform raster addition of the output (reclassed) rasters, then automatically display the final output (raster "SUM) in ArcMap. This is the code that I created.

# Import system modules
import arcpy
from arcpy import env
from import *
import os.path

# Set environment settings
path = "mypath"
env.workspace = path.replace("\\","/")

#To overwrite existing files
arcpy.env.overwriteOutput = True

# Local variables:
F1 = "raster1"
F2 = "raster"
TABLE = "F.dbf" #Table to reclass raster
F1_REC = "raster1_reclass"
F2_REC = "raster2_reclas"
SUM = "sum.tif"

# Check out the ArcGIS Spatial Analyst extension license

# Reclass by Table F1, TABLE, "F1_FROM", "F1_TO", "F2_RE", F1_REC, "DATA")

# Reclass by Table F2, TABLE, "F2_FROM", "F2_TO", "F2_RE", F2_REC, "DATA")

# Process: Add F1_REC and F2_REC
SUM = Raster(F1_REC) + Raster(F2_REC)
Tags : arcgis-10.6

Related Questions

Updated April 26, 2019 21:22 PM

Updated August 14, 2015 17:09 PM

Updated June 09, 2017 00:22 AM

Updated January 26, 2018 17:22 PM