<?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: Composing raster functions with parameters for the input raster(s) in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/composing-raster-functions-with-parameters-for-the/m-p/787534#M1477</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Atma, that sounds very cool to be able to access raster functions as python functions. &amp;nbsp;I look forward to getting my hands on that capability! &amp;nbsp; It's good to know your team is already working on it.&amp;nbsp;Thanks for the tip. &amp;nbsp;That link you provided actually was my starting point for trying out this idea. &amp;nbsp;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Apr 2017 20:15:38 GMT</pubDate>
    <dc:creator>DavidJohnson5</dc:creator>
    <dc:date>2017-04-12T20:15:38Z</dc:date>
    <item>
      <title>Composing raster functions with parameters for the input raster(s)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/composing-raster-functions-with-parameters-for-the/m-p/787532#M1475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to figure out how to wrap a raster function chain into a python function that has parameters&amp;nbsp;for the input raster(s) of the function chain. &amp;nbsp;I also need to display the output in the map widget. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My eventual goal is to&amp;nbsp;create wrappers for &amp;nbsp;function chains which have multiple input branches.&amp;nbsp;But&amp;nbsp;for now, here is a very simple example I have tried which requires only one input raster parameter. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;# code for context.&lt;/P&gt;&lt;P&gt;type(dem_item)&lt;/P&gt;&lt;P&gt;arcgis.gis.item&lt;/P&gt;&lt;P&gt;dem_item.layers&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;lt;ImageryLayer url:"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fdev004545.esri.com%2Farcgis%2Frest%2Fservices%2FHosted%2FNED_1r3_CONUS_Albers_30m%2FImageServer" target="_blank"&gt;http://dev004545.esri.com/arcgis/rest/services/Hosted/NED_1r3_CONUS_Albers_30m/ImageServer&lt;/A&gt;&lt;SPAN&gt;"&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# python&amp;nbsp;wrapper function&lt;/P&gt;&lt;P&gt;def slope_template(in_ras):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"rasterFunction" : "Slope",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"rasterFunctionArguments" : {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"DEM" : in_ras&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;# Add the output of the function to the map widget&lt;/P&gt;&lt;P&gt;map.add_layer(slope_template(dem_item.layers[0]))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Running this code produces the following error. &amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: darkred;"&gt;---------------------------------------------------------------------------&lt;/SPAN&gt;&lt;SPAN class="" style="color: darkred;"&gt;TypeError&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Traceback (most recent call last)&lt;SPAN class="" style="color: darkgreen;"&gt;&amp;lt;ipython-input-26-4095d219143b&amp;gt;&lt;/SPAN&gt; in &lt;SPAN class="" style="color: steelblue;"&gt;&amp;lt;module&amp;gt;&lt;SPAN class="" style="color: darkblue;"&gt;()&lt;/SPAN&gt;&lt;SPAN class="" style="color: darkgreen;"&gt;----&amp;gt; 1&lt;SPAN class="" style="color: #c4a000;"&gt; &lt;/SPAN&gt;map1&lt;SPAN class="" style="color: #c4a000;"&gt;.&lt;/SPAN&gt;add_layer&lt;SPAN class="" style="color: #c4a000;"&gt;(&lt;/SPAN&gt;slope_template&lt;SPAN class="" style="color: #c4a000;"&gt;(&lt;/SPAN&gt;dem_item&lt;SPAN class="" style="color: #c4a000;"&gt;.&lt;/SPAN&gt;layers&lt;SPAN class="" style="color: #c4a000;"&gt;[&lt;/SPAN&gt;0&lt;SPAN class="" style="color: #c4a000;"&gt;]&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c4a000;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c4a000;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c4a000;"&gt;&lt;/SPAN&gt; C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\widgets\__init__.py in add_layer&lt;SPAN class="" style="color: darkblue;"&gt;(self, item, options)&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 142 &lt;SPAN class="" style="color: #c4a000;"&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 143&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self&lt;SPAN class="" style="color: #c4a000;"&gt;.&lt;/SPAN&gt;_addlayer &lt;SPAN class="" style="color: #c4a000;"&gt;=&lt;/SPAN&gt; json&lt;SPAN class="" style="color: #c4a000;"&gt;.&lt;/SPAN&gt;dumps&lt;SPAN class="" style="color: #c4a000;"&gt;(&lt;/SPAN&gt;js_layer&lt;SPAN class="" style="color: #c4a000;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c4a000;"&gt;&lt;/SPAN&gt;--&amp;gt; 144&lt;SPAN class="" style="color: #c4a000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif &lt;SPAN class="" style="color: darkblue;"&gt;'layers'&lt;/SPAN&gt; in item:&amp;nbsp; &lt;SPAN class="" style="color: darkred;"&gt;# items as well as services&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 145&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if item.layers is None:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 146&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise RuntimeError(&lt;SPAN class="" style="color: darkblue;"&gt;'No layers accessible/available in this item or service'&lt;/SPAN&gt;) &lt;SPAN class="" style="color: darkred;"&gt;TypeError&lt;/SPAN&gt;: argument of type 'NoneType' is not iterable

&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/composing-raster-functions-with-parameters-for-the/m-p/787532#M1475</guid>
      <dc:creator>DavidJohnson5</dc:creator>
      <dc:date>2021-12-12T08:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Composing raster functions with parameters for the input raster(s)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/composing-raster-functions-with-parameters-for-the/m-p/787533#M1476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David we are working on a similar concept internally for the next release. With that you can access raster functions as Python functions and greatly simplifies how you use and chain them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Meanwhile, checkout the extract_bands funciton in&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/guide/using-imagery-layers/#Composing-raster-functions"&gt;https://developers.arcgis.com/python/guide/using-imagery-layers/#Composing-raster-functions&lt;/A&gt;&amp;nbsp;which talks about chaining raster functions and writing a method around it. You can use that as a starting point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Apr 2017 19:20:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/composing-raster-functions-with-parameters-for-the/m-p/787533#M1476</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-04-12T19:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Composing raster functions with parameters for the input raster(s)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/composing-raster-functions-with-parameters-for-the/m-p/787534#M1477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Atma, that sounds very cool to be able to access raster functions as python functions. &amp;nbsp;I look forward to getting my hands on that capability! &amp;nbsp; It's good to know your team is already working on it.&amp;nbsp;Thanks for the tip. &amp;nbsp;That link you provided actually was my starting point for trying out this idea. &amp;nbsp;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Apr 2017 20:15:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/composing-raster-functions-with-parameters-for-the/m-p/787534#M1477</guid>
      <dc:creator>DavidJohnson5</dc:creator>
      <dc:date>2017-04-12T20:15:38Z</dc:date>
    </item>
  </channel>
</rss>

