<?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: Round to nearest 100th in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453759#M35631</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;That method works fine for me. Are you sure your field is the right type (long int)?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had no issue with it in arcmap attribute table field calculator. Just in IDLE... My code below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os, math
from arcpy import env


in_workspace = r"F:/Inventory_export_dev/testRnd"
rndValue = "int(round(!ELEVATION!, -2))"
fcList = []
fieldName = "SL_ELEV"


for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.append(os.path.join(dirpath, filename))


for list in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(list, fieldName, "SHORT", "", "", "", "", "NULLABLE")


print "Rounding ELEVATION field to SL_ELEV"


#Rounds values from [ELEVATION] to [SL_ELEV]
for elev in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(elev, fieldName, rndValue, "PYTHON")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;am I missing something?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:14:06 GMT</pubDate>
    <dc:creator>ChrisBrannin</dc:creator>
    <dc:date>2021-12-11T20:14:06Z</dc:date>
    <item>
      <title>Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453752#M35624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am a little confused about how to round a field to the nearest 100th. Would I use math.ceil() or the round()? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;math.ceil([field]/100)*100&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does this only round down though?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 14:57:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453752#M35624</guid>
      <dc:creator>ChrisBrannin</dc:creator>
      <dc:date>2013-06-06T14:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453753#M35625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;math.ceil() always rounds up. math.floor() rounds down. round() rounds the the nearest integer or to a particular decimal place if the second parameter is specified.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;round([field], 2)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 15:05:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453753#M35625</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-06-06T15:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453754#M35626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am a little confused about how to round a field to the nearest 100th. Would I use math.ceil() or the round()? &lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
math.ceil([field]/100)*100
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Does this only round down though?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How I mean to phrase this question is, how to round a number (say 11) to 0 instead of 100?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453754#M35626</guid>
      <dc:creator>ChrisBrannin</dc:creator>
      <dc:date>2021-12-11T20:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453755#M35627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;How I mean to phrase this question is, how to round a number (say 11) to 0 instead of 100?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You would use a negative number for the second round() parameter of course. Use int() to ensure it returns an integer instead of float.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;int(round([field], -2))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 15:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453755#M35627</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-06-06T15:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453756#M35628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You would use a negative number for the second round() parameter of course. Use int() to ensure it returns an integer instead of float.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;int(round([field], -2))&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is the winner right there, thank you! I knew ther was a better way then to use math.ceil(). I really appreciate the help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 15:17:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453756#M35628</guid>
      <dc:creator>ChrisBrannin</dc:creator>
      <dc:date>2013-06-06T15:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453757#M35629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You would use a negative number for the second round() parameter of course. Use int() to ensure it returns an integer instead of float.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;int(round([field], -2))&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I use this outside of arcmap? When I try, an error of "Invalid field [field]" appears.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to use it like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
rndValue = "int(round(!ELEVATION!, -2))"

...

arcpy.CalculateField_management(elev, fieldName, rndValue, "PYTHON")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453757#M35629</guid>
      <dc:creator>ChrisBrannin</dc:creator>
      <dc:date>2021-12-11T20:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453758#M35630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That method works fine for me. Are you sure your field is the right type (long int)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 17:30:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453758#M35630</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-06-06T17:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453759#M35631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;That method works fine for me. Are you sure your field is the right type (long int)?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had no issue with it in arcmap attribute table field calculator. Just in IDLE... My code below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os, math
from arcpy import env


in_workspace = r"F:/Inventory_export_dev/testRnd"
rndValue = "int(round(!ELEVATION!, -2))"
fcList = []
fieldName = "SL_ELEV"


for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.append(os.path.join(dirpath, filename))


for list in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(list, fieldName, "SHORT", "", "", "", "", "NULLABLE")


print "Rounding ELEVATION field to SL_ELEV"


#Rounds values from [ELEVATION] to [SL_ELEV]
for elev in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(elev, fieldName, rndValue, "PYTHON")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;am I missing something?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453759#M35631</guid>
      <dc:creator>ChrisBrannin</dc:creator>
      <dc:date>2021-12-11T20:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453760#M35632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would try printing out your elev value for each iteration of fcList to make sure it is what you expect.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 18:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453760#M35632</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-06-06T18:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453761#M35633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looks like you are trying to round the ELEVATION variable before you have set it to anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Need to either set it or extract it from the attributes first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, both your for loops are working the same data, in one you assign it to list, in the other you assign to elev.&amp;nbsp; But, in both cases, you are still just itering through the values in fcList, so just as well do it in one swoop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Think you are looking for something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os, math
from arcpy import env


in_workspace = r"F:/Inventory_export_dev/testRnd"
fcList = []



for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.append(os.path.join(dirpath, filename))


for list in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(list, fieldName, "SHORT", "", "", "", "", "NULLABLE")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(list, "SL_ELEV", "int(round( !ELEVATION!, -2))", "PYTHON")

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Haven't tested, but should go through each FC in your fcList add the field and populate it with the round value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453761#M35633</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-11T20:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453762#M35634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Deleted my last post after re-reading.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, it looks like you can use one for loop to replace all three that you are running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;might try something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy import os, math from arcpy import env&amp;nbsp;&amp;nbsp; in_workspace = r"F:/Inventory_export_dev/testRnd" fcList = []&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"): &amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(os.path.join(dirpath, filename), fieldName, "SHORT", "", "", "", "", "NULLABLE") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(os.path.join(dirpath, filename), "SL_ELEV", "int(round( !ELEVATION!, -2))", "PYTHON") &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;No need to put the filenames in a list if all you are going to do is iterate through them again.&amp;nbsp; Just as well do the work on the first iteration.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, this will errror out if any of the FC's in your in_workspace do not have the numeric ELEVATION field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 18:59:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453762#M35634</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-06-06T18:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453763#M35635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Deleted my last post after re-reading.&lt;BR /&gt;&lt;BR /&gt;However, it looks like you can use one for loop to replace all three that you are running.&lt;BR /&gt;&lt;BR /&gt;might try something like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os, math
from arcpy import env


in_workspace = r"F:/Inventory_export_dev/testRnd"
fcList = []



for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(os.path.join(dirpath, filename), fieldName, "SHORT", "", "", "", "", "NULLABLE")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(os.path.join(dirpath, filename), "SL_ELEV", "int(round( !ELEVATION!, -2))", "PYTHON")

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;No need to put the filenames in a list if all you are going to do is iterate through them again.&amp;nbsp; Just as well do the work on the first iteration.&lt;BR /&gt;&lt;BR /&gt;Of course, this will errror out if any of the FC's in your in_workspace do not have the numeric ELEVATION field.&lt;BR /&gt;&lt;BR /&gt;R_&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see this works perfectly then. Is there an easy way to skip the files that do not have the elevation field?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453763#M35635</guid>
      <dc:creator>ChrisBrannin</dc:creator>
      <dc:date>2021-12-11T20:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453764#M35636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Replace the work part with this should do it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "ELEVATION" in [f.name for f in arcpy.ListFields(os.path.join(dirpath, filename))]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(os.path.join(dirpath, filename), "SL_ELEV", "SHORT", "", "", "", "", "NULLABLE")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(os.path.join(dirpath, filename), "SL_ELEV", "int(round( !ELEVATION!, -2))", "PYTHON")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "no Elevation field for dataset ", filename

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, you can skip the else: part, only needed if you want it to do something when ELEVATION field not present.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453764#M35636</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-11T20:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453765#M35637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Replace the work part with this should do it:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "ELEVATION" in [f.name for f in arcpy.ListFields(os.path.join(dirpath, filename))]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(os.path.join(dirpath, filename), "SL_ELEV", "SHORT", "", "", "", "", "NULLABLE")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(os.path.join(dirpath, filename), "SL_ELEV", "int(round( !ELEVATION!, -2))", "PYTHON")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "no Elevation field for dataset ", filename

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Of course, you can skip the else: part, only needed if you want it to do something when ELEVATION field not present.&lt;BR /&gt;&lt;BR /&gt;R_&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is seriously great. I tried something like this with no luck. But now I understand why it did not work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if "ELEVATION" == arcpy.ListFields(os.path.join(dirpath, filename)):
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your time with this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453765#M35637</guid>
      <dc:creator>ChrisBrannin</dc:creator>
      <dc:date>2021-12-11T20:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453766#M35638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So you see that it was trying to compare a single string "ELEVATION" to a list of objects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;basically, could do something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

fieldList = arcpy.ListFields(os.path.join(dirpath, filename))

for f in fieldList:
&amp;nbsp;&amp;nbsp; if f.name == "ELEVATION":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(os.path.join(dirpath, filename), "SL_ELEV", "SHORT", "", "", "", "", "NULLABLE")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(os.path.join(dirpath, filename), "SL_ELEV", "int(round( !ELEVATION!, -2))", "PYTHON")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which is the same thing, I just used list comprehension to shorten the list, iterator, and comparison into one line instead of three. (love list comprehension, just wish I were better at it...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453766#M35638</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-11T20:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Round to nearest 100th</title>
      <link>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453767#M35639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to do this in raster calculator? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would Int( Floor( [in_raster] + 0.5 ) ) suffice?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or even Int( [in_raster] + 0.5 ) ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Aug 2013 08:26:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/round-to-nearest-100th/m-p/453767#M35639</guid>
      <dc:creator>wilfredwaters</dc:creator>
      <dc:date>2013-08-28T08:26:58Z</dc:date>
    </item>
  </channel>
</rss>

