<?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 Calculate Field using Python while retaining null values in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-using-python-while-retaining-null/m-p/25995#M926</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had a problem (in 9.2) with nulls and cursors in a python script. Basically, not possible to insert a null. I was getting the value from the row above being copied down instead - absolutely useless. Apparently a known bug, fixed for 9.4/10 and fixed with a service pack for 9.3 - no fix for 9.2 though. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just found this thread &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=262236"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=262236&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The comment "Just some advice some might find useful: The code block option in the Calculate Field tool is nothing more than a gp update cursor in disguise" is interesting. Maybe it's the same problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Apr 2010 06:56:35 GMT</pubDate>
    <dc:creator>DarshaHardy</dc:creator>
    <dc:date>2010-04-23T06:56:35Z</dc:date>
    <item>
      <title>Calculate Field using Python while retaining null values</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-using-python-while-retaining-null/m-p/25994#M925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to use the Calculate Field tool in Model Builder using python (not VB) to convert from meters to miles. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Some records are null, in which case I want them to stay as null. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, in the expression line (using Python 9.3), if I use the following, then nulls become 0, where in VB these would remain as null:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(!HabitatDistance!) * 0.000621371192&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also tried to use Calc and Reclass with a variety of if, else statements, but none of those seem to work. I just get 0's for null input values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: Calc(float(!HabitatDistance_mi!),float(!HabitatDistance_m!))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Codeblock: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def Calc(dist1,dist2):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if dist2 == None:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return None&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return dist2 * 0.000621371192&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any solutions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Apr 2010 17:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-field-using-python-while-retaining-null/m-p/25994#M925</guid>
      <dc:creator>KatieBudreski</dc:creator>
      <dc:date>2010-04-22T17:49:40Z</dc:date>
    </item>
    <item>
      <title>Calculate Field using Python while retaining null values</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-using-python-while-retaining-null/m-p/25995#M926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had a problem (in 9.2) with nulls and cursors in a python script. Basically, not possible to insert a null. I was getting the value from the row above being copied down instead - absolutely useless. Apparently a known bug, fixed for 9.4/10 and fixed with a service pack for 9.3 - no fix for 9.2 though. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just found this thread &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=262236"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=262236&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The comment "Just some advice some might find useful: The code block option in the Calculate Field tool is nothing more than a gp update cursor in disguise" is interesting. Maybe it's the same problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Apr 2010 06:56:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-field-using-python-while-retaining-null/m-p/25995#M926</guid>
      <dc:creator>DarshaHardy</dc:creator>
      <dc:date>2010-04-23T06:56:35Z</dc:date>
    </item>
  </channel>
</rss>

