3

I'm trying to create 50 sets of random point shapefiles in 37 different folders for a total of 1,850 random point shapefiles. However, upon running the script only a handful of sets are actually random. For example, out of 50 sets the first 9 would all be identical, then the next 8 would all be identical, and the next 9 would be identical etc. The function successfully creates a random point file but for some reason makes the exact same file for the next several iterations. Below is my Arcpy script.

for x in range(4,41):

...     for y in range(1,51):      
...   arcpy.CreateRandomPoints_management(filename,str(x)+"kmran"+str(y),"polygonboundary","",157,"","POINT","")

I'm unaware if this is a known bug in either the random point generator tool or arcpy. I'm using ArcGIS 10.3.1.

EDIT: Just to be clear this happens regardless of how many runs or points I generate.

EDIT 2:

SOLVED THE PROBLEM! Turns out that I wasn't giving ArcGIS's random point generator algorithm enough time to create a new set of shapefiles. I threw in a time.sleep(2) at the end of the 2nd loop to add a 2 second delay beteween each file generation and it worked and generated all unique files!

  • +1 Perfect. So ArcGIS using 'normal' approach to re-initiate randomiser, i.e. Timer – FelixIP Apr 7 '16 at 3:31
2

I repeated your test using 1/10th of the sample, i.e. generated 186 random sets for the area 4km*4km, 157 points each.

Results: 30 sets have no clone, 130 has 1 clone.

It means your observation is correct, i.e. with 10 times greater sample, you'd expect 8-9 repeats.

The ones that repeat each other were sequential, e.g. third was clone of second.

It seems there is work to do on improving random generator for ESRI.

I also found that rnd() function in field calculator repeats itself, i.e. randomise seed is set value

|improve this answer|||||
  • I reran the test but this time only created 50 random point shapefile layers. However, I'm still experiencing the problem of having 8-9 reoccurring files in sequential order. So, in essence I'm only actually getting 7-8 unique random point shapefile layers despite there still being 50. I'm still at a loss as to why this is happening. – Brendan W. Apr 6 '16 at 22:48
  • You are having 1/6 of unique sets, same as my result show – FelixIP Apr 6 '16 at 23:54
  • Okay, right. Your answers have helped tremendously with shedding some light on this issue. However, I ran this methodology two weeks ago with 50 points instead of 157 and it produced 50 unique sets of points with no duplicates for each of the 37 iterations. Is there any particular reason why now it would be producing these duplicates? Unfortunately, I specifically need each random point set to be unique with no duplicates. – Brendan W. Apr 7 '16 at 2:03
  • This is a lot to ask for each point being unique. The only solution I can suggest is generation of large dataset = 157*1850 points and split it into 1850 sets. I'd populate new field with !FID! % 157 and split biggie using this value – FelixIP Apr 7 '16 at 2:12
  • It's not so much that each individual point has to be unique but that having all 157 of 157 points within a set match all 157 of 157 points in the previous six sets ruins the point of generating a large batch of random point sets to begin with since only a handful are actually usable. Regardless, thanks again for your help and I'll try the new solution. – Brendan W. Apr 7 '16 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.