<?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: Using SHAPE@X or SHAPE@Y tokens in a selection statement in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062467#M61255</link>
    <description>&lt;P&gt;Looks like that error is referring to a field you have listed as APLIC that maybe doesn't exist in one of the feature classes.&lt;/P&gt;</description>
    <pubDate>Thu, 27 May 2021 17:48:18 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-05-27T17:48:18Z</dc:date>
    <item>
      <title>Using SHAPE@X or SHAPE@Y tokens in a selection statement</title>
      <link>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062453#M61251</link>
      <description>&lt;P&gt;I have a number of point feature classes that are the result of geocoding various types of permits.&amp;nbsp; I have 5 different permit feature classes, and since many of them were issued to same address, they are 'stacked' when viewed on a map.&amp;nbsp; I wrote a simple script that adds and subtracts 5 map units from the &lt;A href="mailto:SHAPE@X" target="_blank"&gt;SHAPE@X&lt;/A&gt;&amp;nbsp;value or the &lt;A href="mailto:SHAPE@Y" target="_blank"&gt;SHAPE@Y&lt;/A&gt;&amp;nbsp;value.&amp;nbsp; That works great when all the records in a feature class have values, but since this feature class is the result of geocoding, those records that did not match have &amp;lt;null&amp;gt; values for their coordinates.&lt;/P&gt;&lt;P&gt;As a result, as I UpdateCursor through the feature class records, and try to perform an additive or subtractive operation the script errors out with something to the effect of 'Sorry Joe, I can't add or subtract from None'&lt;/P&gt;&lt;P&gt;Below is an example of the where clause in a SearchCursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fields = ['SHAPE@X','SHAPE@Y']
select = 'SHAPE@X is not None'

for fc in arcpy.ListFeatureClasses():
    with arcpy.da.SearchCursor(fc,fields,select)as cursor:
        for row in cursor:
            if fc == 'APLIC':
                print(row[0])


Traceback (most recent call last):

  File "&amp;lt;ipython-input-16-18ea27620933&amp;gt;", line 3, in &amp;lt;module&amp;gt;
    for row in cursor:

RuntimeError: An invalid SQL statement was used. [SELECT OBJECTID,Shape FROM APLIC WHERE SHAPE@X is not None]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess I could wrap my cursor in a try/except block block but I'd rather just process those records that have valid values in&amp;nbsp;&amp;nbsp;&lt;A href="mailto:SHAPE@X" target="_blank"&gt;SHAPE@X&lt;/A&gt;&amp;nbsp;and &lt;A href="mailto:SHAPE@Y" target="_blank"&gt;SHAPE@Y&lt;/A&gt;&amp;nbsp;.&amp;nbsp; Is there a way to select for just those records that meet my criteria?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 17:35:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062453#M61251</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-05-27T17:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using SHAPE@X or SHAPE@Y tokens in a selection statement</title>
      <link>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062463#M61253</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/191789"&gt;@BlakeTerhune&lt;/a&gt;&amp;nbsp;looks like you retracted your post as I was replying to it.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;select = 'SHAPE@X is not null'

for fc in arcpy.ListFeatureClasses():
        with arcpy.da.SearchCursor(fc,fields,select)as cursor:
            for row in cursor:
                if fc == 'APLIC':
                    print(row[0])
                    finish = time.strftime('%H:%M:%S')
Traceback (most recent call last):

  File "&amp;lt;ipython-input-20-4b6a74596c64&amp;gt;", line 3, in &amp;lt;module&amp;gt;
    for row in cursor:

RuntimeError: An expected Field was not found or could not be retrieved properly. [APLIC]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is not Null is what I initially tried, but it errors as well.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 17:45:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062463#M61253</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-05-27T17:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using SHAPE@X or SHAPE@Y tokens in a selection statement</title>
      <link>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062465#M61254</link>
      <description>&lt;P&gt;None is not a valid keyword in SQL; try null instead. Also, I'm not sure if you can use the geometry property "token" fields in the where clause. You might have to use shape instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;select = 'SHAPE is not null'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 17:46:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062465#M61254</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-05-27T17:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using SHAPE@X or SHAPE@Y tokens in a selection statement</title>
      <link>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062467#M61255</link>
      <description>&lt;P&gt;Looks like that error is referring to a field you have listed as APLIC that maybe doesn't exist in one of the feature classes.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 17:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062467#M61255</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-05-27T17:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using SHAPE@X or SHAPE@Y tokens in a selection statement</title>
      <link>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062468#M61256</link>
      <description>&lt;P&gt;Yep, that did it!&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 17:48:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-shape-x-or-shape-y-tokens-in-a-selection/m-p/1062468#M61256</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-05-27T17:48:25Z</dc:date>
    </item>
  </channel>
</rss>

