<?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: Create random points loop in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/create-random-points-loop/m-p/1143626#M63740</link>
    <description>&lt;P&gt;try making the join permanent (eg.&amp;nbsp; a new featureclass and see if that solves the problem&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 15:16:13 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-02-14T15:16:13Z</dc:date>
    <item>
      <title>Create random points loop</title>
      <link>https://community.esri.com/t5/python-questions/create-random-points-loop/m-p/1143611#M63739</link>
      <description>&lt;P&gt;I have shapefile with several different fields in which there is data that needs to be converted into random points. Currently I have been using the Create Random Points (Data Management) tool, which works really well but is very timeconsuming when i have a lot of these that I want to process. What I am wondering is if there is a way to automate this with a loop so I only have to do this once per shapefile, or perhaps once per GDB? My coding skills are lacking at best (although I am learning), so I am not sure this will work.&lt;/P&gt;&lt;P&gt;My Idea is that the script should loop through all fields and use the field name as outName and Numfield.&lt;/P&gt;&lt;P&gt;This is what it currently looks like, but I am getting errors which i'm not&amp;nbsp; sure I understand. The latter seems to be because the table field is a join field, but I don't see another way of describing the field other than with the field name.&lt;/P&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;LI-CODE lang="python"&gt;import arcpy

arcpy.env.overwriteOutput = True

fieldList = ["T_Flekke_spes_mat$_.Heterogen", "T_Flekke_spes_mat$_.Grå", "T_Flekke_spes_mat$_.Bryozo", "T_Flekke_spes_mat$_.Hvit_grov", "T_Flekke_spes_mat$_.Lys_fin", "T_Flekke_spes_mat$_.Mørk_fin", "T_Flekke_spes_mat$_.Uspesifisert"]

for field in fieldList:
    outGDB = "D:\ArcGIS\HV\HV.gdb"
    outName = field
    conFC = "D:\ArcGIS\HV\HV.gdb\Årbogen_lag_1"
    numField = field
    arcpy.CreateRandomPoints_management(outGDB, outName, conFC, "", numField)&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;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;---------------------------------------------------------------------------&lt;/SPAN&gt;
&lt;SPAN class=""&gt;ExecuteError&lt;/SPAN&gt;                              Traceback (most recent call last)
In  &lt;SPAN class=""&gt;[3]&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;12&lt;/SPAN&gt;:    arcpy.CreateRandomPoints_management(outGDB, outName, conFC, &lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;, numField)

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;CreateRandomPoints&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;21598&lt;/SPAN&gt;: &lt;SPAN class=""&gt;raise&lt;/SPAN&gt; e

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;CreateRandomPoints&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;21595&lt;/SPAN&gt;: retval = convertArcObjectToPythonObject(gp.CreateRandomPoints_management(*gp_fixargs((out_path, out_name, constraining_feature_class, constraining_extent, number_of_points_or_field, minimum_allowed_distance, create_multipoint_output, multipoint_size), &lt;SPAN class=""&gt;True&lt;/SPAN&gt;)))

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;&amp;lt;lambda&amp;gt;&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;512&lt;/SPAN&gt;:   &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;lambda&lt;/SPAN&gt; *args: val(*gp_fixargs(args, &lt;SPAN class=""&gt;True&lt;/SPAN&gt;))

&lt;SPAN class=""&gt;ExecuteError&lt;/SPAN&gt;: Failed to execute. Parameters are not valid.
ERROR 000728: Field T_Flekke_spes_mat$_.Heterogen does not exist within table
Failed to execute (CreateRandomPoints).

&lt;SPAN class=""&gt;---------------------------------------------------------------------------&lt;/SPAN&gt;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Feb 2022 14:40:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-random-points-loop/m-p/1143611#M63739</guid>
      <dc:creator>ErikKjellman</dc:creator>
      <dc:date>2022-02-14T14:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create random points loop</title>
      <link>https://community.esri.com/t5/python-questions/create-random-points-loop/m-p/1143626#M63740</link>
      <description>&lt;P&gt;try making the join permanent (eg.&amp;nbsp; a new featureclass and see if that solves the problem&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 15:16:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-random-points-loop/m-p/1143626#M63740</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-14T15:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create random points loop</title>
      <link>https://community.esri.com/t5/python-questions/create-random-points-loop/m-p/1146093#M63828</link>
      <description>&lt;P&gt;Thanks, that did the trick!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 08:50:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-random-points-loop/m-p/1146093#M63828</guid>
      <dc:creator>ErikKjellman</dc:creator>
      <dc:date>2022-02-21T08:50:23Z</dc:date>
    </item>
  </channel>
</rss>

