<?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 Re: Customised tool in ArcGIS using ArcPy in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1087734#M11426</link>
    <description>&lt;P&gt;Looking at your code I think it should be something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Two tools combining here
#Feature to raster conversion - Not sure how to write the output raster from this step. 
arcpy.FeatureToRaster_conversion (in_features, "", save_raster, 25)
#In the next line, the condition i would like to apply is if there is value within the raster layer, it gets newValue(user defined), otherwise 1 
OutRas = Con(IsNull(save_raster), 1, newValue)

OutRas.save(save_raster)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Aug 2021 23:09:41 GMT</pubDate>
    <dc:creator>DavinWalker2</dc:creator>
    <dc:date>2021-08-10T23:09:41Z</dc:date>
    <item>
      <title>Customised tool in ArcGIS using ArcPy</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1087681#M11425</link>
      <description>&lt;P&gt;I am trying to combine two operations (Feature to raster and Conditional operation) using python script in ArcGIS to create a customized tool. I would like this tool to be transferable so my friends can feed in their inputs - polygons and conditions, to get a raster output.&lt;/P&gt;&lt;P&gt;I have a polygon shapefile with me. Firstly, I would like to convert the polygons into a raster. Secondly, the rasterized polygons need to get values like 10% or 20% (user-specified values) the rest (outside polygons) gets a value of 1.&lt;/P&gt;&lt;P&gt;To do this I have attempted with a script, then got stuck. My python knowledge is minimal so please excuse me for silly mistakes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I guess the error is where I don't know how to define the output from the feature to raster conversion. The script is here:&lt;/P&gt;&lt;P&gt;I am trying to combine two operations (Feature to raster and Conditional operation) using python script in ArcGIS to create a customized tool. I would like this tool to be transferable so my friends can feed in their inputs.&lt;/P&gt;&lt;P&gt;I have a polygon shapefile with me. Firstly, I would like to convert the polygons into a raster. Secondly, the rasterized polygons need to get values like 10% or 20% (user-specified values) the rest (outside polygons) gets a value of 1.&lt;/P&gt;&lt;P&gt;To do this I have attempted with a script, then got stuck. It would be great if you could guide me through it. My python knowledge is minimal so please excuse me for silly mistakes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I guess the error is where I don't know how to define the output from the feature to raster conversion. The script is here:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; sys
&lt;SPAN class="hljs-keyword"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; env
&lt;SPAN class="hljs-keyword"&gt;from&lt;/SPAN&gt; arcpy.sa &lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; * &lt;SPAN class="hljs-comment"&gt;#Import all modules in arcpy.sa path&lt;/SPAN&gt;
arcpy.CheckOutExtension(&lt;SPAN class="hljs-string"&gt;"Spatial"&lt;/SPAN&gt;)  &lt;BR /&gt;
&lt;SPAN class="hljs-comment"&gt;#The environments for the work is set up here&lt;/SPAN&gt;
arcpy.env.cellSize = &lt;SPAN class="hljs-number"&gt;25&lt;/SPAN&gt; 
arcpy.env.overwriteOutput = &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt; &lt;BR /&gt;
in_features = arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;) &lt;SPAN class="hljs-comment"&gt;# In tool,Datatype is feature class&lt;/SPAN&gt;
folder = arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;) &lt;SPAN class="hljs-comment"&gt;# In tool, Location of output folder&lt;/SPAN&gt;
raster = arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;2&lt;/SPAN&gt;) &lt;SPAN class="hljs-comment"&gt;#In tool, output raster name is defined as string in the tool&lt;/SPAN&gt;

&lt;SPAN class="hljs-comment"&gt;# newValue&lt;/SPAN&gt;
newValue = &lt;SPAN class="hljs-built_in"&gt;float&lt;/SPAN&gt;(arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;3&lt;/SPAN&gt;)) &lt;SPAN class="hljs-comment"&gt;# use float or int and assigned as strings in the tool&lt;/SPAN&gt;

&lt;SPAN class="hljs-comment"&gt;#The formatable folder location and name for output&lt;/SPAN&gt;
arcpy.AddMessage(&lt;SPAN class="hljs-string"&gt;"Folder: {}"&lt;/SPAN&gt;.&lt;SPAN class="hljs-built_in"&gt;format&lt;/SPAN&gt;(folder))
arcpy.AddMessage(&lt;SPAN class="hljs-string"&gt;"Raster: {}"&lt;/SPAN&gt;.&lt;SPAN class="hljs-built_in"&gt;format&lt;/SPAN&gt;(raster))
save_raster = os.path.join(folder, raster)
arcpy.AddMessage(&lt;SPAN class="hljs-string"&gt;"Save Location: {}"&lt;/SPAN&gt;.&lt;SPAN class="hljs-built_in"&gt;format&lt;/SPAN&gt;(save_raster))

&lt;SPAN class="hljs-comment"&gt;#Two tools combining here&lt;BR /&gt;&lt;/SPAN&gt;#Feature to raster conversion - Not sure how to write the output raster from this step. 
arcpy.FeatureToRaster_conversion (in_features, &lt;SPAN class="hljs-string"&gt;""&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;out_raster&lt;/SPAN&gt;, &lt;SPAN class="hljs-number"&gt;25&lt;/SPAN&gt;)&lt;BR /&gt;#In the next line, the condition i would like to apply is if there is value within the raster layer, it gets newValue(user defined), otherwise 1 
OutRas = Con(out_raster, &lt;SPAN class="hljs-string"&gt;""&lt;/SPAN&gt;, newValue, &lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;)
OutRas.save(save_raster)&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Aug 2021 21:02:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1087681#M11425</guid>
      <dc:creator>Deepa</dc:creator>
      <dc:date>2021-08-10T21:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Customised tool in ArcGIS using ArcPy</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1087734#M11426</link>
      <description>&lt;P&gt;Looking at your code I think it should be something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Two tools combining here
#Feature to raster conversion - Not sure how to write the output raster from this step. 
arcpy.FeatureToRaster_conversion (in_features, "", save_raster, 25)
#In the next line, the condition i would like to apply is if there is value within the raster layer, it gets newValue(user defined), otherwise 1 
OutRas = Con(IsNull(save_raster), 1, newValue)

OutRas.save(save_raster)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 23:09:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1087734#M11426</guid>
      <dc:creator>DavinWalker2</dc:creator>
      <dc:date>2021-08-10T23:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Customised tool in ArcGIS using ArcPy</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1087880#M11427</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I defined OBJECTID as the field and the script is here:&lt;/P&gt;&lt;P&gt;#Two tools combining here&lt;BR /&gt;field = "OBJECTID"&lt;BR /&gt;arcpy.FeatureToRaster_conversion (in_features, field, save_raster, 25)&lt;BR /&gt;OutRas = Con(IsNull(save_raster), 1, newValue)&lt;BR /&gt;OutRas.save(save_raster)&lt;/P&gt;&lt;P&gt;However when i try to run the script tool with the changes as you suggested i get a final raster map with wrong&amp;nbsp; values like in the image attached(The expected result is a raster map with values 0.01 and 1) . Also ArcMap crashes after this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Deepa_0-1628687885362.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20621i05CE577A7D538FF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Deepa_0-1628687885362.png" alt="Deepa_0-1628687885362.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 13:21:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1087880#M11427</guid>
      <dc:creator>Deepa</dc:creator>
      <dc:date>2021-08-11T13:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Customised tool in ArcGIS using ArcPy</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1088328#M11432</link>
      <description>&lt;P&gt;The script worked when i changed the datatype as work space in tool parameters and saved output in geodatabase. Also made a minor change in script like this.&lt;/P&gt;&lt;P&gt;field = "OBJECTID"&lt;BR /&gt;arcpy.FeatureToRaster_conversion (in_features, field, "out1", 25)&lt;BR /&gt;OutRas = Con(IsNull("out1"), 1, newValue)&lt;BR /&gt;OutRas.save(save_raster)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your helpful inputs &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 09:19:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/customised-tool-in-arcgis-using-arcpy/m-p/1088328#M11432</guid>
      <dc:creator>Deepa</dc:creator>
      <dc:date>2021-08-12T09:19:57Z</dc:date>
    </item>
  </channel>
</rss>

