<?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: calculate geometry values for specific fc type in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173023#M13329</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you need more print statements, your script is returning an empty list, so you will have to back up a few lines and check your inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and check your syntax and case ... etc Feature not feature &lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listdatasets.htm" title="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listdatasets.htm"&gt;ListDatasets—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 May 2016 22:16:14 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-05-12T22:16:14Z</dc:date>
    <item>
      <title>calculate geometry values for specific fc type</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173022#M13328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wasn't sure how to name this post...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a geodatabase with multiple feature datasets, each containing multiple feature classes of various polygon, line and point geometry type.&amp;nbsp; Every polygon fc has a 'areaSize' field that I need to populate with square feet (all of the fds are in State Plane feet). &lt;/P&gt;&lt;P&gt;I think I'm getting close here, but still getting an error.&amp;nbsp; (Eventually I will expand this to perform a similar calculation for length of line fc types as well.&lt;/P&gt;&lt;P&gt;The error I receive is attached.&amp;nbsp; Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#*********************************
#v1.0
#*********************************
import arcpy
from arcpy import env
import os

#Set variables
inputgdb = sys.argv[1]

#Set workspace
arcpy.env.workspace = inputgdb

#populate areaSize fields in polygon feature classes
datasetList = arcpy.ListDatasets(feature_type = 'feature')
datasetList = [''] + datasetList if datasetList is not None else []
print "Getting Feature Datasets..."
arcpy.AddMessage ("Getting Feature Datasets...")
print datasetList
arcpy.AddMessage (datasetList)

for dataset in datasetList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = inputgdb + "\\" + dataset
&amp;nbsp;&amp;nbsp;&amp;nbsp; dataset = dataset + "\\"
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList = arcpy.ListFeatureClasses('*', 'polygon', '*')
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Getting Feature Classes..."
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage ("Getting Feature Classes...")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature Class list..."
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage (fcList)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc = fc +"\\"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList = [f.name for f in arcpy.ListFields(fc, "areaSize")]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor (fc, fieldList) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&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; row[1] = row[0].area
&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; cursor.updateRow(row)
&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; print "Updating 'areaSize' field in: " + fc
&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; arcpy.AddMessage ("Updating 'areaSize' field in: " + fc)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:56:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173022#M13328</guid>
      <dc:creator>JustinWolff</dc:creator>
      <dc:date>2021-12-11T08:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: calculate geometry values for specific fc type</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173023#M13329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you need more print statements, your script is returning an empty list, so you will have to back up a few lines and check your inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and check your syntax and case ... etc Feature not feature &lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listdatasets.htm" title="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listdatasets.htm"&gt;ListDatasets—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2016 22:16:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173023#M13329</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-12T22:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: calculate geometry values for specific fc type</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173024#M13330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see a couple of larger, structural issues with the code, but I don't have time to elaborate at the moment.&amp;nbsp; Regarding the specific error message, you can make it go away by changing Line 25 to:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14631021159292984" data-renderedposition="60_8_1203_16" jivemacro_uid="_14631021159292984"&gt;&lt;P&gt;fcList = arcpy.ListFeatureClasses(&lt;SPAN class="string"&gt;'*', 'polygon', ''&lt;/SPAN&gt;)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14631021278057111 jive_macro_code jive_text_macro" data-renderedposition="102_8_1203_16" jivemacro_uid="_14631021278057111"&gt;&lt;P&gt;fcList = arcpy.ListFeatureClasses(&lt;SPAN class="string"&gt;'*', 'polygon'&lt;/SPAN&gt;)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfeatureclasses.htm"&gt;ListFeatureClasses &lt;/A&gt;documentation covers the syntax of the tool.&amp;nbsp; There is no asterisk wildcard for the feature_dataset parameter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2016 01:17:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173024#M13330</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-05-13T01:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: calculate geometry values for specific fc type</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173025#M13331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan and Josh - thank you very much for the nudge in the right direction.&amp;nbsp; It's still far from elegant, but it is now working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#*********************************
#v1.0
#*********************************
import arcpy
from arcpy import env
import os
#Set variables
inputgdb = sys.argv[1]
#Set workspace
arcpy.env.workspace = inputgdb
#populate areaSize fields in polygon feature classes
datasetList = arcpy.ListDatasets(feature_type = 'Feature')
datasetList = [''] + datasetList if datasetList is not None else []
print "Getting Feature Datasets..."
arcpy.AddMessage ("Getting Feature Datasets...")
print datasetList
arcpy.AddMessage (datasetList)
for dataset in datasetList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = inputgdb + "\\" + dataset
&amp;nbsp;&amp;nbsp;&amp;nbsp; dataset = dataset + "\\"
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList = arcpy.ListFeatureClasses('*', 'polygon', '')
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Getting Feature Classes..."
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage ("Getting Feature Classes...")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature Class list..."
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage (fcList)

&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc = fc +"\\"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #fieldList = [f.name for f in arcpy.ListFields(fc, "areaSize")]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor (fc, ['SHAPE@AREA', 'areaSize']) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&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; row[1] = row[0]
&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; cursor.updateRow(row)
&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; print "Updating 'areaSize' field in: " + fc
&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; arcpy.AddMessage ("Updating 'areaSize' field in: " + fc)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Changing lines 30 and 32 is really all it took.&amp;nbsp; I still have some cleanup to do, then expand it to populate other fields, etc.&amp;nbsp; But this is a great start.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173025#M13331</guid>
      <dc:creator>JustinWolff</dc:creator>
      <dc:date>2021-12-11T08:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: calculate geometry values for specific fc type</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173026#M13332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just for future reference, questions should be flagged as questions so they can be marked Correct if someone provides you an answer.&amp;nbsp; In this case with this question, you flagged it as a discussion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2016 13:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173026#M13332</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-05-13T13:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: calculate geometry values for specific fc type</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173027#M13333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would probably do something like this to avoid showing a message for each record in the featureclass and add the field in case it doesn't exist:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

gdb = arcpy.GetParameterAsText(0)
arcpy.env.workspace = gdb
fld_area = 'areaSize'

fdss = arcpy.ListDatasets('*', 'Feature')
fdss.append('')

for fds in fdss:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Feature Datasets: {0}'.format(fds))
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses('*', 'Polygon', fds)

&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc_name in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc = os.path.join(gdb, fds, fc_name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(' - Updating areaSize in Featureclass: {0}'.format(fc_name))

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # check if field exists, if not add it
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(arcpy.ListFields(fc, fld_area)) != 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(fc, fld_area, 'DOUBLE')

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor (fc, ('SHAPE@AREA', fld_area)) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&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; i += 1
&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; if i % 100 == 0:
&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; arcpy.AddMessage('&amp;nbsp; - Updating record: {0}'.format(i))
&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; row[1] = row[0]
&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; cursor.updateRow(row)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, I didn't test the code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:56:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-values-for-specific-fc-type/m-p/173027#M13333</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T08:56:54Z</dc:date>
    </item>
  </channel>
</rss>

