<?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: Issue with Python Script not reading geometry length in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1071674#M61468</link>
    <description>&lt;P&gt;Sorry Dan, I must have misunderstood. In any case I finally realized where I was going wrong, and I was able to easily correct the issue.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 20:03:43 GMT</pubDate>
    <dc:creator>RPGIS</dc:creator>
    <dc:date>2021-06-23T20:03:43Z</dc:date>
    <item>
      <title>Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1069956#M61395</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I came across a very strange issue, one that I never had issues with previously and then all of sudden I started having issues. The issue is the length field for one of the feature classes isn't reading for some reason. It was able to read in the past but now it doesn't seem to be reading it. I have tested it in a notebook as well as a standalone script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import sys
import os

workspace = *

sewerin_fcs = *

ws_split = os.path.split(workspace)

fcs = []

walk = arcpy.da.Walk(workspace, datatype="FeatureClass")

for dirpath, dirnames, filenames in walk:
        for filename in filenames:
                #Get feature class name
                fcsname = os.path.basename(filename)
                name = os.path.splitext(fcsname)
                y = name[1].lstrip('.')

                if y == sewerin_fcs:
                        fcs.append(os.path.join(dirpath, filename))


for fc in fcs:
        fc_fields = []

        
        important_fields = ['OBJECTID', 'SHAPE@LENGTH']

        allfields = arcpy.ListFields(fc)
        for field in allfields:
                #print field.name
                if field.name in important_fields:
                        print (field.name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the script finishes running, this is the printed result.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Printed Result.JPG" style="width: 607px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16327iF47E8542DFCEDA3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Printed Result.JPG" alt="Printed Result.JPG" /&gt;&lt;/span&gt;&amp;nbsp;standalone script.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jupyter Notebook Result.JPG" style="width: 140px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16328i40F71446B165F8BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Jupyter Notebook Result.JPG" alt="Jupyter Notebook Result.JPG" /&gt;&lt;/span&gt;Jupyter Notebook script&lt;/P&gt;&lt;P&gt;It appears that the database in which these fields are sourced is the issue. When I checked all of the feature classes in the database that also have this field, the script wasn't working. I don't know if has something to do with field visibility or a setting within the database itself.&lt;/P&gt;&lt;P&gt;The script creates a detailed report of all the important feature classes within multiple databases within the default sde databases and compares those feature classes to the multiple databases within our production database. I am not sure how this issue can be resolved, but it is something that I don't quite know on how to trouble shoot.&lt;/P&gt;&lt;P&gt;I would greatly appreciate it if someone could assist me with this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 19:13:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1069956#M61395</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-06-18T19:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1069968#M61396</link>
      <description>&lt;P&gt;What database are you on?&lt;/P&gt;&lt;P&gt;We are on oracle. For this sort of stuff, I use SQL embedded in python (or sometimes pure SQL) It is much faster than going through arcpy.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 19:37:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1069968#M61396</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2021-06-18T19:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070041#M61401</link>
      <description>&lt;P&gt;case sensitive?&lt;/P&gt;&lt;P&gt;Shape_Length&amp;nbsp; in my gdb featureclass&lt;/P&gt;&lt;P&gt;You are safer reading the shape field directly and getting the geometry from it using the SHAPE@ token&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 21:37:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070041#M61401</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-18T21:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070436#M61415</link>
      <description>&lt;P&gt;Thanks forestknutsen,&lt;/P&gt;&lt;P&gt;I haven't tried using sql from python and I don't quite know the what correct module is needed to access the sde database or if there is already an existing module that is installed in python that will allow me to access the sde database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know if the module is already there when python is installed or is there another module that you are using to access the database? I have been looking and I think there is an already installed module, but I am not sure if the module that is installed has full SQL querying capabilities or if it is limited.&lt;/P&gt;&lt;P&gt;If it isn't too much to ask, would you mind letting me know. I am trying to generate several reports simultaneously and for the most part, the script works but there is the issue of this single dataset that for some reason is prohibiting the length field from being read for some of the feature classes.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 14:04:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070436#M61415</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-06-21T14:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070477#M61418</link>
      <description>&lt;P&gt;Thanks Dan,&lt;/P&gt;&lt;P&gt;Does the shape field also read the length field as well? I just need the length field for a report that the script prints out with details on the specified feature classes with their total combined lengths for each record and print a text file of those total lengths.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 15:20:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070477#M61418</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-06-21T15:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070538#M61420</link>
      <description>&lt;P&gt;Robert, I was initially pointing out that my shape length field is&amp;nbsp;&lt;SPAN&gt;Shape_Length and not&lt;/SPAN&gt; &amp;nbsp;&lt;A href="mailto:SHAPE@LENGTH" target="_blank"&gt;SHAPE@LENGTH&lt;/A&gt;&amp;nbsp; which is token to read the shape field and return the length.... it is different, it is reading the actual shapefield and returning a property.&lt;/P&gt;&lt;P&gt;If you are reading actual fields, use their field names, if you want to read the tokens for the fields, then use those ( OID@ and &lt;A href="mailto:SHAPE@LENGTH" target="_blank"&gt;SHAPE@LENGTH&lt;/A&gt;&amp;nbsp;for file gdb )&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 16:07:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070538#M61420</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-21T16:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070675#M61423</link>
      <description>&lt;P&gt;Thanks Dan,&lt;/P&gt;&lt;P&gt;I also tried using the field name as well and the result was still the same. So I tried using the &lt;A href="mailto:shape@length" target="_blank"&gt;shape@length&lt;/A&gt;&amp;nbsp;for the featureclass(s) to see if the result would be different but the result didn't change. I am under the impression that the issue perhaps lies in the database itself and its permissions, but one of our dbas is looking into it.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 20:03:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070675#M61423</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-06-21T20:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070678#M61424</link>
      <description>&lt;P&gt;Robert, my examples are for file geodatabases.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 20:05:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070678#M61424</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-21T20:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070821#M61433</link>
      <description>&lt;P&gt;No problem. I use cx_oracle.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://cx-oracle.readthedocs.io/en/latest/" target="_blank"&gt;https://cx-oracle.readthedocs.io/en/latest/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;of course, it only works on sde deployments with oracle as the base technology. You have to install it (it does come as part of the standard library).&lt;/P&gt;&lt;P&gt;There is also&amp;nbsp;ArcSDESQLExecute:&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/10.6/analyze/arcpy-classes/arcsdesqlexecute.htm" target="_blank"&gt;https://desktop.arcgis.com/en/arcmap/10.6/analyze/arcpy-classes/arcsdesqlexecute.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It does not require an install (part of arcpy). And it does not care what your dbms technology is. But it is not as nice to use as cx_oracle. So, I almost never use it. Let me know if you are on oracle and I will post a code sample.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 03:29:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1070821#M61433</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2021-06-22T03:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1071673#M61467</link>
      <description>&lt;P&gt;Thanks forestknutsen1.&lt;/P&gt;&lt;P&gt;We use SQL databases so anything Oracle related I wouldn't be able to use. Thank you though for the offer, I will let you know if we end up utilizing something related to Oracle where that kind of script would come in handy.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:02:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1071673#M61467</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-06-23T20:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Python Script not reading geometry length</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1071674#M61468</link>
      <description>&lt;P&gt;Sorry Dan, I must have misunderstood. In any case I finally realized where I was going wrong, and I was able to easily correct the issue.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:03:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-python-script-not-reading-geometry/m-p/1071674#M61468</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-06-23T20:03:43Z</dc:date>
    </item>
  </channel>
</rss>

