<?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: da.SearchCursor ORDER BY SHAPE@AREA in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343662#M26902</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1, SQL Server&lt;/P&gt;&lt;P&gt;2. I'm guessing ST_geometry since&amp;nbsp;Shape.STArea() is the name of the area column on polygon FC's.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Feb 2017 18:43:32 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2017-02-07T18:43:32Z</dc:date>
    <item>
      <title>da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343659#M26899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not having any success sorting an arcpy.da.SearchCursor by the SHAPE Area values.&amp;nbsp; No errors but it doesn't sort descending from my testing. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone able to confirm this or offer a suggestion?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;clip_fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SHAPE@AREA'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'POLYGON_NM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;sql_clause&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'ORDER BY SHAPE.STArea() DESC'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; clipcur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; cliprow &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; clipcur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; areaval &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; cliprow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:11:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343659#M26899</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T16:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343660#M26900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This appears to be one solution:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; cliprow &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; sorted&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;clip_fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SHAPE@AREA'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'POLYGON_NM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;reverse&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:12:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343660#M26900</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T16:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343661#M26901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is your backend database and what geometry storage type is being used?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:37:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343661#M26901</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-02-07T18:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343662#M26902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1, SQL Server&lt;/P&gt;&lt;P&gt;2. I'm guessing ST_geometry since&amp;nbsp;Shape.STArea() is the name of the area column on polygon FC's.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:43:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343662#M26902</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-02-07T18:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343663#M26903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just tested with ArcMap 10.5 connecting to a 10.4.x enterprise geodatabase in SQL Server, and using a SQL clause works:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'Database Connections\Default@SGDB@localdb.sde\SGDB.DBO.Infra'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"SHAPE@AREA"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"OID@"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;sql_clause&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ORDER BY SHAPE.STArea() DESC"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; area&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;oid &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{} {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;area&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;oid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;39593.1062297&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;26339.7586344&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;20269.7498507&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;8894.95466122&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;11&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;8412.44189983&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;8049.8586996&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;7620.10032388&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;10&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;7431.46963174&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;6953.70626041&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;8&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;6316.28689426&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;9&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;6142.45012789&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:12:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343663#M26903</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T16:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343664#M26904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have any comment on the solution I mentioned above?&amp;nbsp; (It's linked to from the &lt;A href="https://resources.arcgis.com/en/help/main/10.1/index.html#/SearchCursor/018w00000011000000/"&gt;10.1 documentation&lt;/A&gt;&amp;nbsp;under example #5 "sorting Mini-HOW TO" -- which I thought was strange).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:45:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343664#M26904</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-02-07T18:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343665#M26905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like I implemented the same but the cursor was not sorted as expected!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: I'm on ArcGIS 10.3&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:47:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343665#M26905</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-02-07T18:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343666#M26906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SQL Server doesn't support ST_Geometry.&amp;nbsp; For SQL Server it will be GEOMETRY or GEOGRAPHY if using native types, or SDEBINARY if using an Esri type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343666#M26906</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-02-07T18:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343667#M26907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorted is a Python built-in, and your code is following a standard Python pattern.&amp;nbsp; If it works, great.&amp;nbsp; A couple of things to think about.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Sorted returns "a new sorted list from the items in &lt;EM&gt;iterable&lt;/EM&gt;."&amp;nbsp; In this case, it means your entire cursor will have to be iterated and stored in a new list before sorted sorts it and gives you a list back.&amp;nbsp; For very large data sets, it may not be desirable to copy the entire cursor into memory.&lt;/LI&gt;&lt;LI&gt;Since your cursor is returning more than one field, it would be best for you to specify a &lt;EM&gt;key&lt;/EM&gt; to select the one and only column you are interested in sorting on.&amp;nbsp; In your current example, you are actually comparing a combination of&amp;nbsp;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;SHAPE@AREA &lt;/SPAN&gt;and &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;POLYGON_NM&lt;/SPAN&gt;, whatever the latter is.&amp;nbsp; For the &lt;EM&gt;key&lt;/EM&gt;, you can either use &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;operator.itemgetter()&lt;/SPAN&gt; or define a lambda/anonymous function to select just the area field.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:58:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343667#M26907</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-02-07T18:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: da.SearchCursor ORDER BY SHAPE@AREA</title>
      <link>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343668#M26908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;itemgetter implemented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 19:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-searchcursor-order-by-shape-area/m-p/343668#M26908</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-02-07T19:58:56Z</dc:date>
    </item>
  </channel>
</rss>

