Hey Guys,
I'm trying to use the tool "Create Random Points (Data Management)" in order to distribute 1 random point per Polygon using arcpy. My script is the following:
arcpy.CreateRandomPoints_management(out_path = "C:/Data/", out_name="random.shp", constraining_feature_class="C:/Data/Grid3b.shp", number_of_points_or_field=1)
The weird thing is, the output create contains the expected amout of points, but they all have the same coordinates (i.e. are "on top of each other) and are far off from where they should be. I've uploaded my the constraining shapefile here, can someone help me out?
Solved! Go to Solution.
Could you please run repair geometry on the Grid3b and then use Create random points. When I ran the repair geometry I found problem with 24 features in this file.
Result:
"WARNING 000986: C:\Users\.........Local\Temp\Grid3b0.txt contains the full list of non simple features.
WARNING 000461: Repaired feature 0 because of incorrect ring ordering, ...., ......, ......, ...... WARNING 000461: Repaired feature 24 because of incorrect ring ordering"
Regards
Kishor
Try using following syntax. Currently I do not have access to advanced license to test the behavior.
arcpy.CreateRandomPoints_management(r'C:\Temp',"Random.shp",r'C:\Temp\Grid3b.shp',"","1","","POINT","")
Hope this is helpful
Kishor
Thanks for your answer! Unfortunalty, the result ist the same. 49 Points, as expected, but all on top of each other with weird coordinates (9.85771519532085e-273 /1.02643732661912e-299 rather than somewhere around 600000 / 200000).
Could you please run repair geometry on the Grid3b and then use Create random points. When I ran the repair geometry I found problem with 24 features in this file.
Result:
"WARNING 000986: C:\Users\.........Local\Temp\Grid3b0.txt contains the full list of non simple features.
WARNING 000461: Repaired feature 0 because of incorrect ring ordering, ...., ......, ......, ...... WARNING 000461: Repaired feature 24 because of incorrect ring ordering"
Regards
Kishor
Indeed, the problem lies with an error in my shapefile! I drew the grid myself using an arcpy and pyshp and drew each square counterclockwise. Apperently, this only was a problem when I applied the random points tool. Thank you so much for the advice!