-1

Here is my dilemma. I really hope someone can help soon! Generate 150 random points inside the boundaries of a shapefile that are also 1000 meters away from each other

here is what I have tried:

import arcpy, random, os
outGDB = 'E:\Python\week_4\week_4_topost\data\example_data.gdb'
numPoints = 150
minDistance = "1000 Meters"
outName = "testpoints.shp"
conFC = "Cache.shp"
arcpy.CreateRandomPoints_management(outGDB, outName, conFC, "", numPoints, minDistance)

here is my error message:

ExecuteError                              Traceback (most recent call last)
<ipython-input-65-e5cc74ba6ed5> in <module>()
      5 outName = "testpoints.shp"
      6 conFC = "Cache.shp"
----> 7 arcpy.CreateRandomPoints_management(outGDB, outName, conFC, "", numPoints, minDistance)

C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\management.py in CreateRandomPoints(out_path, out_name, constraining_feature_class, constraining_extent, number_of_points_or_field, minimum_allowed_distance, create_multipoint_output, multipoint_size)
  17530         return retval
  17531     except Exception as e:
> 17532         raise e
  17533 
  17534 @gptooldoc('GeneratePointsAlongLines_management', None)

ExecuteError: ERROR 000354: The name contains invalid characters
Failed to execute (CreateRandomPoints).

Also I have been using this link for a while trying to figure it out but no use.

craq
  • 1,441
  • 2
  • 20
  • 39

1 Answers1

2

I figured it out! I needed to add the workspace line and make some smaller modifications to the code so it should look like this

output_gdb = r'E:\Python\week_4\week_4_topost\data\example_data.gdb'
arcpy.env.workspace = output_gdb
print output_gdb
boundary = 'Cache'
output_location = arcpy.CreateRandomPoints_management(output_gdb, 'Random_Points', boundary, None, 150, "1 Kilometer")