<?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 Randomly select points in a feature layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/randomly-select-points-in-a-feature-layer/m-p/1181396#M7467</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a feature layer (points). So, I'd like to randomly select several points based on the value in one of the columns ('level_' column).&lt;/P&gt;&lt;P&gt;For instance, I'd like to randomly select 16 points of level 1 and 10 of level 2, then I will use the result to plan a route using&amp;nbsp;&lt;EM&gt;plan_routes().&lt;/EM&gt;&amp;nbsp; &amp;nbsp;The thing is that I don't want the two results separate because I need them to be in the same feature so I can use them as input for planning the routes.&lt;/P&gt;&lt;P&gt;In the code below I queried the feature layer to get only the points of level 1 &amp;amp; 2.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# query parcels - level 1 &amp;amp; 2
m_levels = test.query(where="level_= '1' OR level_='2'")
m_levels&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jun 2022 10:40:06 GMT</pubDate>
    <dc:creator>MVAC</dc:creator>
    <dc:date>2022-06-09T10:40:06Z</dc:date>
    <item>
      <title>Randomly select points in a feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/randomly-select-points-in-a-feature-layer/m-p/1181396#M7467</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a feature layer (points). So, I'd like to randomly select several points based on the value in one of the columns ('level_' column).&lt;/P&gt;&lt;P&gt;For instance, I'd like to randomly select 16 points of level 1 and 10 of level 2, then I will use the result to plan a route using&amp;nbsp;&lt;EM&gt;plan_routes().&lt;/EM&gt;&amp;nbsp; &amp;nbsp;The thing is that I don't want the two results separate because I need them to be in the same feature so I can use them as input for planning the routes.&lt;/P&gt;&lt;P&gt;In the code below I queried the feature layer to get only the points of level 1 &amp;amp; 2.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# query parcels - level 1 &amp;amp; 2
m_levels = test.query(where="level_= '1' OR level_='2'")
m_levels&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 10:40:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/randomly-select-points-in-a-feature-layer/m-p/1181396#M7467</guid>
      <dc:creator>MVAC</dc:creator>
      <dc:date>2022-06-09T10:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select points in a feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/randomly-select-points-in-a-feature-layer/m-p/1181602#M7475</link>
      <description>&lt;P&gt;The Python random package does what you ask. The function random.sample for sampling without replacement and random.choices for sampling with replacement.&lt;/P&gt;&lt;P&gt;Then all you have to do is get the data into Python.&amp;nbsp; In arcpy there is&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/data-access/featureclasstonumpyarray.htm" target="_blank" rel="noopener"&gt;FeatureClassToNumPyArray&lt;/A&gt;&amp;nbsp; In the Arcgis API there is the spatially enabled dataframe&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/guide/introduction-to-the-spatially-enabled-dataframe/#:~:text=The%20Spatially%20Enabled%20DataFrame%20(SEDF,you%20may%20be%20familiar%20with" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/guide/introduction-to-the-spatially-enabled-dataframe/#:~:text=The%20Spatially%20Enabled%20DataFrame%20(SEDF,you%20may%20be%20familiar%20with&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 19:20:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/randomly-select-points-in-a-feature-layer/m-p/1181602#M7475</guid>
      <dc:creator>DavidAnderson_1701</dc:creator>
      <dc:date>2022-06-09T19:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select points in a feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/randomly-select-points-in-a-feature-layer/m-p/1181727#M7476</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 08:04:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/randomly-select-points-in-a-feature-layer/m-p/1181727#M7476</guid>
      <dc:creator>MVAC</dc:creator>
      <dc:date>2022-06-10T08:04:08Z</dc:date>
    </item>
  </channel>
</rss>

