<?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 Assigning random numbers to points in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449429#M1549</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: cdeaner66&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to assign random numbers to point features.&amp;nbsp; I have tried using the calculate field tool using the following expression arcgis.rand("Integer 1 16") but rather than assign the features the numbers 1-16 it randomly distributes the values so I may end up with no points with the number 3 and 2 points with the number 9 for example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know how to modify this code or use a different expression to randomly assign the points a number?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Nov 2011 17:26:15 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2011-11-23T17:26:15Z</dc:date>
    <item>
      <title>Assigning random numbers to points</title>
      <link>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449429#M1549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: cdeaner66&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to assign random numbers to point features.&amp;nbsp; I have tried using the calculate field tool using the following expression arcgis.rand("Integer 1 16") but rather than assign the features the numbers 1-16 it randomly distributes the values so I may end up with no points with the number 3 and 2 points with the number 9 for example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know how to modify this code or use a different expression to randomly assign the points a number?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 17:26:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449429#M1549</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-11-23T17:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning random numbers to points</title>
      <link>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449430#M1550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Sycosys&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Calculate a field to have random values derived from a uniform distribution of integers between 0 and 16&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcgisscripting, sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# An input feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;inputFC = sys.argv[1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.AddField_management(inputFC, "Value", "LONG")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management(inputFC, "Value", "arcgis.rand('Integer 0 16')", "PYTHON", "#")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 17:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449430#M1550</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-11-23T17:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning random numbers to points</title>
      <link>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449431#M1551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was able to get the following to work w/o returning any duplicates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-logic Script&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def update():
&amp;nbsp; import arcpy, random
&amp;nbsp; mylist = []
&amp;nbsp; x = 1
&amp;nbsp; while x &amp;lt;= 16:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mylist.append(x)
&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp; x = 1
&amp;nbsp; rows = arcpy.UpdateCursor(r"C:\temp\python\test.gdb\Fires")
&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = random.choice(mylist)
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Sample = y
&amp;nbsp;&amp;nbsp;&amp;nbsp; val = row.Sample
&amp;nbsp;&amp;nbsp;&amp;nbsp; mylist.remove(y)
&amp;nbsp; del row, rows
&amp;nbsp; return val&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:03:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449431#M1551</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T20:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning random numbers to points</title>
      <link>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449432#M1552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: JSkinn3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not tried in the field calculator, but I was able to get the following code to work and it did not return any duplicates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, random

mylist = []

x = 1

while x &amp;lt;= 16:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mylist.append(x)
&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1

rows = arcpy.UpdateCursor(r"C:\temp\python\test.gdb\Fires")

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = random.choice(mylist)
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Random = y
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; mylist.remove(y)

del row, rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/assigning-random-numbers-to-points/m-p/449432#M1552</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T20:03:50Z</dc:date>
    </item>
  </channel>
</rss>

