<?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: Random Selection of Preexisting Points w/ Definition Query in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176984#M13623</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priscilla,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the modification, it worked quite well including setting a def query before executing. And thanks for contacting ESRI about this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jan 2019 00:22:33 GMT</pubDate>
    <dc:creator>RobertCelestin1</dc:creator>
    <dc:date>2019-01-08T00:22:33Z</dc:date>
    <item>
      <title>Random Selection of Preexisting Points w/ Definition Query</title>
      <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176978#M13617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hi everyone,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I want to use definition queries with this code, taken from &lt;STRONG&gt;&lt;A href="https://support.esri.com/en/technical-article/000013141" style="color: #000000;" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;SPAN style="text-decoration: underline;"&gt;this&lt;/SPAN&gt; &lt;/A&gt;&lt;/STRONG&gt;ESRI page, in order to randomly select a subset of preexisting points by count:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; SelectRandomByCount &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; random
 layerCount &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput &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="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; layerCount &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"input count is greater than layer count"&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt;
 oids &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;oid &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; oid&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&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;layer&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;
 oidFldName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;OIDFieldName
 delimOidFld &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddFieldDelimiters &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; oidFldName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 randOids &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; random&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sample &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;oids&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 oidsStr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;", "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;map &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; randOids&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{0} IN ({1})"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;delimOidFld&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; oidsStr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
__________________________________________________________________
SelectRandomByPercent &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; num&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;/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;P style="color: #595959; background-color: #ffffff; font-weight: 300; font-size: 0.9rem; margin-bottom: 1.55rem; padding: 2px;"&gt;&lt;SPAN style="color: #000000;"&gt;The code works with a shapefile, but does not work for me with a personal geodatabase. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;My desired scenario with using a definition query is as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I have 27,000 points in one layer and 511 polygons in another. The points are draw over the polygons &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;and are only contained within the boundaries of the polygons. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Phase One: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;1. I want to first filter out a subset of points, using a simple definition query (e.g. "ID = #") that&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;is set via the layer properties&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;2. I want to randomly select a max number of points from the layer that has the definition query set,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;using the script above&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;3. Once that selection is made, I will assign the selected points a unique name in a field i've created.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Phase Two: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;1. I want to set a definition query and repeat Phase One - Step 1. with the addition of excluding&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt; the points assigned a name.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Can anyone help with this? I've attached a representation of the points and polygons. Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Best,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;Robert&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:06:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176978#M13617</guid>
      <dc:creator>RobertCelestin1</dc:creator>
      <dc:date>2021-12-11T09:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Random Selection of Preexisting Points w/ Definition Query</title>
      <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176979#M13618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You mention definition query several times, but you are posting Python code.&amp;nbsp; Since definition queries are written in SQL, are you using the Python code to return a list of OIDs to base the definition query on?&amp;nbsp; Reading over Phase One, you talk about setting a definition query in Step 2 but then making a selection in Step 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of describing the process you think you need to follow, can you summarize what you want the outcome to be?&amp;nbsp; My impression is that you want to randomly group features in a feature class and assign each group a new label in a new field, is that what you are trying to do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Dec 2018 14:25:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176979#M13618</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-12-04T14:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Random Selection of Preexisting Points w/ Definition Query</title>
      <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176980#M13619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="color: #000000;"&gt;The code works with a shapefile, but does not work for me with a personal geodatabase. &lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you explain "does not work" a bit more.&amp;nbsp; Are you getting an error message; if so, what?&amp;nbsp; Are you working in the Python window in ArcMap, or as a stand-alone script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code appears to work with a file geodatabase.&amp;nbsp; I was successful in selecting a random group of points in a feature layer.&amp;nbsp; If I understand what you want to do, it seems that line 14 in your code could be an &lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-data-access/updatecursor-class.htm"&gt;update cursor&lt;/A&gt;&amp;nbsp;that uses the "sql" where clause to update a field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2018 03:28:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176980#M13619</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2018-12-05T03:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Random Selection of Preexisting Points w/ Definition Query</title>
      <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176981#M13620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for replying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the confusion. I am not using the python code to return an OID to use in a definition query. The definition query is set before the python code is used, in order to first confine the set of points I am working with. The first image that I attached to my post is an example of that confined set of points. The second image is an example of what results from using the python code on the points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are correct in your impression of what i'd like the outcome to be. However, I do not want to select/assign all points to groups at the same time. To properly reiterate my desired outcome: I would like to randomly select some points (no greater than a max number that I define) from a specific set of points (a subset of the 27,000). Then assign that selection a label in a new field. After this, I need to repeat the process of random selection on&amp;nbsp;the same initial&amp;nbsp;specific set of points, but exclude those points that have already been assigned a label.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever I go through the process of random selection, I only wanted to work with a subset of points from the layer of 27,000. This is why I thought to use a definition query.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 03:06:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176981#M13620</guid>
      <dc:creator>RobertCelestin1</dc:creator>
      <dc:date>2018-12-19T03:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Random Selection of Preexisting Points w/ Definition Query</title>
      <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176982#M13621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested your code on a personal geodatabase and I found where it's getting stuck. The arcpy field delimiters function isn't returning the corrector delimiter. Personal geodatabases need square brackets wrapping their fields for SQL queries, but instead it's wrapping with double quotes. I added in a test to detect if the datasource is coming from a .mdb.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE - I plan to report to ESRI about the field delimiter bug. This arcpy function shouldn't be behaving in this way.&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;import&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; random

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; SelectRandomByCount &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; count&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;&amp;nbsp;layerCount &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput &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="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; layerCount &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"input count is greater than layer count"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oids &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;oid &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; oid&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&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;layer&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;".mdb"&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"["&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;OIDFieldName &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"]"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddFieldDelimiters &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;OIDFieldName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;randOids &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; random&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sample &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;oids&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oidsStr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;", "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;map &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; randOids&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;&amp;nbsp;sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{0} IN ({1})"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; oidsStr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql&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;/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 09:06:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176982#M13621</guid>
      <dc:creator>PriscillaCole</dc:creator>
      <dc:date>2021-12-11T09:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Random Selection of Preexisting Points w/ Definition Query</title>
      <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176983#M13622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you have a Geostatistical Analyst license you could use the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/geostatistical-analyst-toolbox/subset-features.htm"&gt;SubsetFeatures &lt;/A&gt;geoprocessing tool.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2018 15:01:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176983#M13622</guid>
      <dc:creator>SteveLynch</dc:creator>
      <dc:date>2018-12-28T15:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Random Selection of Preexisting Points w/ Definition Query</title>
      <link>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176984#M13623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priscilla,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the modification, it worked quite well including setting a def query before executing. And thanks for contacting ESRI about this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jan 2019 00:22:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/random-selection-of-preexisting-points-w/m-p/176984#M13623</guid>
      <dc:creator>RobertCelestin1</dc:creator>
      <dc:date>2019-01-08T00:22:33Z</dc:date>
    </item>
  </channel>
</rss>

