<?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: How to establish a threshold (raster) between two values in Python? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/how-to-establish-a-threshold-raster-between-two/m-p/771122#M5225</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm a bit confused... you want to create a raster by only maintaining the values in a range and you want to do this in Python. This question is also located in the Big Data&amp;nbsp;space. What software (parts of the platform) do you have at your disposal?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Normally this is easily done manually using the Raster Calculator:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/raster-calculator.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/raster-calculator.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Raster Calculator—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp; (ArcMap) or&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/raster-calculator.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/raster-calculator.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Raster Calculator—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;(ArcGIS Pro)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could simply specify a formula like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Con(myRaster &amp;gt;= 1000, Con(myRaster &amp;lt;= 4000, myRaster))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/394491_pastedImage_3.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Python you can do something similar:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sa &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CheckOutExtension&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Spatial"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

dem &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Raster&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\GeoNet\DEMrange\data.gdb\dem'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dem &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dem &lt;SPAN class="operator token"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dem&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
result&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\GeoNet\DEMrange\data.gdb\result'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... but is it really necessary to do this in Python?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 08:36:58 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-12T08:36:58Z</dc:date>
    <item>
      <title>How to establish a threshold (raster) between two values in Python?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-establish-a-threshold-raster-between-two/m-p/771121#M5224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to establish a threshold (2 values) on a raster image. Values are between 1000 and 4000. How can I write python syntax to do that. Here is an example of what I tried...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inraster_threshold = inraster &amp;gt;=1000 and &amp;lt;=4000&lt;/P&gt;&lt;P&gt;inraster_threshold = inraster &amp;gt;=1000&amp;lt;=4000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;both did come out with syntax errors and I can't find the "and" way of including the second value for my threshold&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jan 2018 20:06:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-establish-a-threshold-raster-between-two/m-p/771121#M5224</guid>
      <dc:creator>HugoCrites</dc:creator>
      <dc:date>2018-01-22T20:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to establish a threshold (raster) between two values in Python?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-establish-a-threshold-raster-between-two/m-p/771122#M5225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm a bit confused... you want to create a raster by only maintaining the values in a range and you want to do this in Python. This question is also located in the Big Data&amp;nbsp;space. What software (parts of the platform) do you have at your disposal?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Normally this is easily done manually using the Raster Calculator:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/raster-calculator.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/raster-calculator.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Raster Calculator—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp; (ArcMap) or&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/raster-calculator.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/raster-calculator.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Raster Calculator—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;(ArcGIS Pro)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could simply specify a formula like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Con(myRaster &amp;gt;= 1000, Con(myRaster &amp;lt;= 4000, myRaster))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/394491_pastedImage_3.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Python you can do something similar:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sa &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CheckOutExtension&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Spatial"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

dem &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Raster&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\GeoNet\DEMrange\data.gdb\dem'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dem &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dem &lt;SPAN class="operator token"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dem&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
result&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\GeoNet\DEMrange\data.gdb\result'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... but is it really necessary to do this in Python?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:36:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-establish-a-threshold-raster-between-two/m-p/771122#M5225</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T08:36:58Z</dc:date>
    </item>
  </channel>
</rss>

