<?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 Set Null value for raster datasets in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/set-null-value-for-raster-datasets/m-p/361474#M28534</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; I need to use SetNull function several times to extracting the required values from the raster dataset.&lt;BR /&gt;&lt;BR /&gt;I am using the following line of code, and the tool is running without any error; but it is not providing the desired output.&lt;BR /&gt;&lt;BR /&gt;arcpy.gp.RasterCalculator_sa("SetNull(ZMAXRas == -99,ZMAXRas)",outWorkspace + inputASCII [:-4] + "_W")&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I recommend using the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/00p6/00p600000002000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;10.x Python map algebra&lt;/A&gt;&lt;SPAN&gt; instead. This enables more efficiency in processing and also is easier to read/debug. (Raster Calculator is really more for interactive use or ModelBuilder.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this and see if it works better:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
from arcpy.sa import *
arcpy.env.workspace = outWorkspace
ZMAXRas = Raster(ZMAXRas) &lt;SPAN style="font-style:italic;"&gt;# convert a path to a raster object&lt;/SPAN&gt;
outRas = SetNull(ZMAXRas == -99,ZMAXRas)
outRas.save(inputASCII[:-4] + "_W")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:51:57 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T16:51:57Z</dc:date>
    <item>
      <title>Set Null value for raster datasets</title>
      <link>https://community.esri.com/t5/python-questions/set-null-value-for-raster-datasets/m-p/361473#M28533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am writing a Python code to automate a process. In it I need to use SetNull function several times to extracting the required values from the raster dataset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the following line of code, and the tool is running without any error; but it is not providing the desired output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.gp.RasterCalculator_sa("SetNull(ZMAXRas == -99,ZMAXRas)",outWorkspace + inputASCII [:-4] + "_W")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Where, ZMAXRas is the input raster variable; outWorkspace and inputASCII are the others variables, those I have used for to retain the naming convention of my output data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone please suggest why I am not getting the raster without '-99' value after running the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For your information, I am using ArcGIS 10.1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Trina.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Mar 2013 09:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-null-value-for-raster-datasets/m-p/361473#M28533</guid>
      <dc:creator>TrinaChakravarty</dc:creator>
      <dc:date>2013-03-08T09:45:49Z</dc:date>
    </item>
    <item>
      <title>Set Null value for raster datasets</title>
      <link>https://community.esri.com/t5/python-questions/set-null-value-for-raster-datasets/m-p/361474#M28534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; I need to use SetNull function several times to extracting the required values from the raster dataset.&lt;BR /&gt;&lt;BR /&gt;I am using the following line of code, and the tool is running without any error; but it is not providing the desired output.&lt;BR /&gt;&lt;BR /&gt;arcpy.gp.RasterCalculator_sa("SetNull(ZMAXRas == -99,ZMAXRas)",outWorkspace + inputASCII [:-4] + "_W")&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I recommend using the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/00p6/00p600000002000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;10.x Python map algebra&lt;/A&gt;&lt;SPAN&gt; instead. This enables more efficiency in processing and also is easier to read/debug. (Raster Calculator is really more for interactive use or ModelBuilder.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this and see if it works better:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
from arcpy.sa import *
arcpy.env.workspace = outWorkspace
ZMAXRas = Raster(ZMAXRas) &lt;SPAN style="font-style:italic;"&gt;# convert a path to a raster object&lt;/SPAN&gt;
outRas = SetNull(ZMAXRas == -99,ZMAXRas)
outRas.save(inputASCII[:-4] + "_W")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:51:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-null-value-for-raster-datasets/m-p/361474#M28534</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T16:51:57Z</dc:date>
    </item>
    <item>
      <title>Set Null value for raster datasets</title>
      <link>https://community.esri.com/t5/python-questions/set-null-value-for-raster-datasets/m-p/361475#M28535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply. It is working now. I tried both ways; the main problem was with the conversion of the path to raster. Anyway thank you very much again for your suggestion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Trina&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 15:16:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-null-value-for-raster-datasets/m-p/361475#M28535</guid>
      <dc:creator>TrinaChakravarty</dc:creator>
      <dc:date>2013-03-11T15:16:41Z</dc:date>
    </item>
  </channel>
</rss>

