<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Custom Weighted Overlay Tool (Python) Not Automatically Adding Output to Map Document in ArcMap Questions</title>
    <link>https://community.esri.com/t5/arcmap-questions/custom-weighted-overlay-tool-python-not/m-p/1157129#M3611</link>
    <description>&lt;P&gt;I am attempting to develop a custom Weighted Overlay tool (via Python script). This tool is based on the utility of the Weighted Overlay (Spatial Analyst) tool. I would like for the user to input only the layer weight values (0% - 100%) and be presented with the output weighted overlay raster layer. I have hard-coded the four input raster data layers, which is the goal. I have developed a script that correctly creates the new layer, but the newly created output raster data layer is not automatically added to the map document. Is there something I can add to my script to accomplish this automatic addition?&lt;/P&gt;&lt;P&gt;Here is the script that I am using to publish this geoprocessing service:&lt;/P&gt;&lt;P&gt;# FireIncidentRiskAnalysis.py&lt;BR /&gt;# Usage: FireIncidentRiskAnalysis &amp;lt;Fire_Incident_Risk_Analysis&amp;gt;&lt;BR /&gt;# Description:&lt;BR /&gt;# ---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;# Import arcpy module&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.workspace = arcpy.env.scratchGDB&lt;/P&gt;&lt;P&gt;StationProximity = arcpy.GetParameter(0)&lt;BR /&gt;if StationProximity == '#' or not StationProximity:&lt;BR /&gt;StationProximity = 25&lt;BR /&gt;&lt;BR /&gt;Landuse = arcpy.GetParameter(1)&lt;BR /&gt;if Landuse == '#' or not Landuse:&lt;BR /&gt;Landuse = 25&lt;BR /&gt;&lt;BR /&gt;HazardousSiteProximity = arcpy.GetParameter(2)&lt;BR /&gt;if HazardousSiteProximity == '#' or not HazardousSiteProximity:&lt;BR /&gt;HazardousSiteProximity = 25&lt;/P&gt;&lt;P&gt;HydrantProximity = arcpy.GetParameter(3)&lt;BR /&gt;if HydrantProximity == '#' or not HydrantProximity:&lt;BR /&gt;HydrantProximity = 25&lt;/P&gt;&lt;P&gt;# Script arguments&lt;BR /&gt;#Fire_Incident_Risk_Analysis = arcpy.GetParameterAsText(0)&lt;BR /&gt;#if Fire_Incident_Risk_Analysis == '#' or not Fire_Incident_Risk_Analysis:&lt;BR /&gt;Fire_Incident_Risk_Analysis = "C:\\CapstoneProject\\Project_Toolbox\\FireIncidentRiskAssessment\\FireIncidentRiskAssessment.gdb\\AnalysisOutput" # provide a default value if unspecified&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Local variables:&lt;BR /&gt;Proximity_to_Fire_Station_Raster = "ParcelsNearStationRaster"&lt;BR /&gt;Landuse_Raster = "LanduseReclass"&lt;BR /&gt;Hazardous_Material_Site_Buffer_Raster = "HazardousMaterialSites"&lt;BR /&gt;Fire_Hydrant_Buffer_Raster = "FireHydrantDistanceBuffers"&lt;/P&gt;&lt;P&gt;remapstation = RemapValue([[1,4],[2,3],[3,2],[4,1],["NODATA","NODATA"]])&lt;BR /&gt;remaplanduse = RemapValue([[1,4],[2,3],[3,2],[4,1],["NODATA","NODATA"]])&lt;BR /&gt;remaphazardous = RemapValue([[1,4],[2,3],[3,2],[4,1],["NODATA","NODATA"]])&lt;BR /&gt;remaphydrant = RemapValue([[1,5],[2,4],[3,3],[4,1],["NODATA","NODATA"]])&lt;/P&gt;&lt;P&gt;myWOTable = WOTable([[Proximity_to_Fire_Station_Raster, StationProximity, "VALUE", remapstation],&lt;BR /&gt;[Landuse_Raster, Landuse, "VALUE", remaplanduse],&lt;BR /&gt;[Hazardous_Material_Site_Buffer_Raster, HazardousSiteProximity, "VALUE", remaphazardous],&lt;BR /&gt;[Fire_Hydrant_Buffer_Raster, HydrantProximity, "VALUE", remaphydrant]], [1, 5, 1])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Execute WeightedOverlay&lt;BR /&gt;WeightedOverlayOutput = WeightedOverlay(myWOTable)&lt;/P&gt;&lt;P&gt;arcpy.CopyRaster_management(WeightedOverlayOutput, Fire_Incident_Risk_Analysis)&lt;BR /&gt;#WeightedOverlayOutput.save(Fire_Incident_Risk_Analysis)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2022 02:09:07 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2022-03-24T02:09:07Z</dc:date>
    <item>
      <title>Custom Weighted Overlay Tool (Python) Not Automatically Adding Output to Map Document</title>
      <link>https://community.esri.com/t5/arcmap-questions/custom-weighted-overlay-tool-python-not/m-p/1157129#M3611</link>
      <description>&lt;P&gt;I am attempting to develop a custom Weighted Overlay tool (via Python script). This tool is based on the utility of the Weighted Overlay (Spatial Analyst) tool. I would like for the user to input only the layer weight values (0% - 100%) and be presented with the output weighted overlay raster layer. I have hard-coded the four input raster data layers, which is the goal. I have developed a script that correctly creates the new layer, but the newly created output raster data layer is not automatically added to the map document. Is there something I can add to my script to accomplish this automatic addition?&lt;/P&gt;&lt;P&gt;Here is the script that I am using to publish this geoprocessing service:&lt;/P&gt;&lt;P&gt;# FireIncidentRiskAnalysis.py&lt;BR /&gt;# Usage: FireIncidentRiskAnalysis &amp;lt;Fire_Incident_Risk_Analysis&amp;gt;&lt;BR /&gt;# Description:&lt;BR /&gt;# ---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;# Import arcpy module&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.workspace = arcpy.env.scratchGDB&lt;/P&gt;&lt;P&gt;StationProximity = arcpy.GetParameter(0)&lt;BR /&gt;if StationProximity == '#' or not StationProximity:&lt;BR /&gt;StationProximity = 25&lt;BR /&gt;&lt;BR /&gt;Landuse = arcpy.GetParameter(1)&lt;BR /&gt;if Landuse == '#' or not Landuse:&lt;BR /&gt;Landuse = 25&lt;BR /&gt;&lt;BR /&gt;HazardousSiteProximity = arcpy.GetParameter(2)&lt;BR /&gt;if HazardousSiteProximity == '#' or not HazardousSiteProximity:&lt;BR /&gt;HazardousSiteProximity = 25&lt;/P&gt;&lt;P&gt;HydrantProximity = arcpy.GetParameter(3)&lt;BR /&gt;if HydrantProximity == '#' or not HydrantProximity:&lt;BR /&gt;HydrantProximity = 25&lt;/P&gt;&lt;P&gt;# Script arguments&lt;BR /&gt;#Fire_Incident_Risk_Analysis = arcpy.GetParameterAsText(0)&lt;BR /&gt;#if Fire_Incident_Risk_Analysis == '#' or not Fire_Incident_Risk_Analysis:&lt;BR /&gt;Fire_Incident_Risk_Analysis = "C:\\CapstoneProject\\Project_Toolbox\\FireIncidentRiskAssessment\\FireIncidentRiskAssessment.gdb\\AnalysisOutput" # provide a default value if unspecified&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Local variables:&lt;BR /&gt;Proximity_to_Fire_Station_Raster = "ParcelsNearStationRaster"&lt;BR /&gt;Landuse_Raster = "LanduseReclass"&lt;BR /&gt;Hazardous_Material_Site_Buffer_Raster = "HazardousMaterialSites"&lt;BR /&gt;Fire_Hydrant_Buffer_Raster = "FireHydrantDistanceBuffers"&lt;/P&gt;&lt;P&gt;remapstation = RemapValue([[1,4],[2,3],[3,2],[4,1],["NODATA","NODATA"]])&lt;BR /&gt;remaplanduse = RemapValue([[1,4],[2,3],[3,2],[4,1],["NODATA","NODATA"]])&lt;BR /&gt;remaphazardous = RemapValue([[1,4],[2,3],[3,2],[4,1],["NODATA","NODATA"]])&lt;BR /&gt;remaphydrant = RemapValue([[1,5],[2,4],[3,3],[4,1],["NODATA","NODATA"]])&lt;/P&gt;&lt;P&gt;myWOTable = WOTable([[Proximity_to_Fire_Station_Raster, StationProximity, "VALUE", remapstation],&lt;BR /&gt;[Landuse_Raster, Landuse, "VALUE", remaplanduse],&lt;BR /&gt;[Hazardous_Material_Site_Buffer_Raster, HazardousSiteProximity, "VALUE", remaphazardous],&lt;BR /&gt;[Fire_Hydrant_Buffer_Raster, HydrantProximity, "VALUE", remaphydrant]], [1, 5, 1])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Execute WeightedOverlay&lt;BR /&gt;WeightedOverlayOutput = WeightedOverlay(myWOTable)&lt;/P&gt;&lt;P&gt;arcpy.CopyRaster_management(WeightedOverlayOutput, Fire_Incident_Risk_Analysis)&lt;BR /&gt;#WeightedOverlayOutput.save(Fire_Incident_Risk_Analysis)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 02:09:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/custom-weighted-overlay-tool-python-not/m-p/1157129#M3611</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-24T02:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Weighted Overlay Tool (Python) Not Automatically Adding Output to Map Document</title>
      <link>https://community.esri.com/t5/arcmap-questions/custom-weighted-overlay-tool-python-not/m-p/1157328#M3613</link>
      <description>&lt;P&gt;you should be able to use arcpy.mapping to add the layer to the dataframe:&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/addlayer.htm" target="_self" rel="nofollow noopener noreferrer"&gt;Add Layer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 14:59:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/custom-weighted-overlay-tool-python-not/m-p/1157328#M3613</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-03-24T14:59:23Z</dc:date>
    </item>
  </channel>
</rss>

