<?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: Generate clustered random point data with set number of points in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256857#M65339</link>
    <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;Thank you for your response, this is a neat way of doing it!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I experimented a bit and it looks like using a high cluster radius (~max 5000) with a low cluster point count (~max 50) distributes the points nicely across the study area. The overlapping makes it look a bit more natural too.&lt;/P&gt;&lt;P&gt;I agree the irregular boundaries would be less obvious than circles, would you be able to elaborate on how would I go about randomly offsetting the points?&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Matthew&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MatthewPoppleton_0-1675998612055.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62532iF2DA79253DEC4746/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MatthewPoppleton_0-1675998612055.png" alt="MatthewPoppleton_0-1675998612055.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 03:17:42 GMT</pubDate>
    <dc:creator>MatthewPoppleton</dc:creator>
    <dc:date>2023-02-10T03:17:42Z</dc:date>
    <item>
      <title>Generate clustered random point data with set number of points</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256589#M65300</link>
      <description>&lt;P&gt;I am working on a simulation to compare different models' estimates of population counts in areas with known total observations. I am using a preset amount of points (e.g. 50,000) to represent observations within my study area, and run models using line transects that overlap with those points.&lt;/P&gt;&lt;P&gt;I currently have a spatially balanced point feature class that acts as a uniform distribution, and another with point clustering based on land-cover type (stationary). I am trying to figure out a way to generate a third point feature class of 50,000 non-stationary randomly clustered points.&lt;/P&gt;&lt;P&gt;What I've tried so far is using the "Generate Random Points" tool to generate 50,000 points within my boundary, and set a low minimum allowed distance (e.g. 1 meter). Then I used the "Density-based clustering" tool to detect areas of clustered points and copied them to a new feature class. This leaves me with the clustered areas and no noise points. However with the noise subtracted I am left with far less than the desired amount of points. The output looks good but I would like to set the total number of points to be clustered. See screenshots for reference.&lt;/P&gt;&lt;P&gt;I could use a higher count of random points and use trial and error to end up with a clustered set around 50,000 but this wouldn't be ideal as I wouldn't have an exact count and it probably wouldn't be very replicable.&lt;/P&gt;&lt;P&gt;I assume this has been done before but I haven't been able to find how. Is there a way to achieve this using other geoprocessing tools or perhaps arcpy?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 17:26:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256589#M65300</guid>
      <dc:creator>MatthewPoppleton</dc:creator>
      <dc:date>2023-02-09T17:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Generate clustered random point data with set number of points</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256705#M65316</link>
      <description>&lt;P&gt;A naive approach:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;create clusters with random point counts until you reach 50k points&lt;/LI&gt;&lt;LI&gt;create random center points for the clusters&lt;/LI&gt;&lt;LI&gt;create buffers with random radii around the cluster centers&lt;/LI&gt;&lt;LI&gt;use these buffers as constraining fc for the Random Points tool&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import random

# tool parameters
output_folder = ""
output_name = "RandomPointClusters"

constraining_fc = "TestPolygons"

num_of_points = 50000

min_points_in_cluster = 20
max_points_in_cluster = 100

min_cluster_radius = 500
max_cluster_radius = 1500

min_point_distance = 1


# randomly distribute the points into clusters
rest = num_of_points
clusters = []
while rest &amp;gt; 0:
    num = random.randint(min_points_in_cluster, max_points_in_cluster)
    num = min(num, rest)
    clusters.append(num)
    rest -= num
print(f"{len(clusters)} clusters will be created.")

# randomly create the cluster centers
cluster_centers = arcpy.management.CreateRandomPoints("memory", "ClusterCenters", constraining_fc, None, len(clusters), min_point_distance)

# randomly create the cluster buffers
sr = arcpy.Describe(constraining_fc).spatialReference
cluster_buffers = arcpy.management.CreateFeatureclass("memory", "ClusterBuffers", "POLYGON", spatial_reference=sr)
arcpy.management.AddField(cluster_buffers, "NumOfPoints", "LONG")
with arcpy.da.InsertCursor(cluster_buffers, ["SHAPE@", "NumOfPoints"]) as i_cursor:
    with arcpy.da.SearchCursor(cluster_centers, ["SHAPE@", "OID@"]) as s_cursor:
        for cluster_center, cluster_id in s_cursor:
            cluster_radius = random.randint(min_cluster_radius, max_cluster_radius)
            cluster_buffer = cluster_center.buffer(cluster_radius)
            num = clusters[cluster_id - 1]
            i_cursor.insertRow([cluster_buffer, num])

# clip the cluster buffers with the constraining fc
cluster_boundaries = arcpy.analysis.Clip(cluster_buffers, constraining_fc, "memory/ClusterBoundaries")

# randomly distribute the points inside the cluster boundaries
arcpy.management.CreateRandomPoints(output_folder, output_name, cluster_boundaries, None, "NumOfPoints", min_point_distance)&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 class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1675975809306.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62479i3FD6F2DD95B4D7A8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1675975809306.png" alt="JohannesLindner_0-1675975809306.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1675975976083.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62481iB60C7D63B956C3C7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1675975976083.png" alt="JohannesLindner_1-1675975976083.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This would be better with irregular cluster boundaries, as now it's very noticeable that they are circles. A random offset for each point could do the trick, too.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 20:53:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256705#M65316</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-09T20:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Generate clustered random point data with set number of points</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256857#M65339</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;Thank you for your response, this is a neat way of doing it!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I experimented a bit and it looks like using a high cluster radius (~max 5000) with a low cluster point count (~max 50) distributes the points nicely across the study area. The overlapping makes it look a bit more natural too.&lt;/P&gt;&lt;P&gt;I agree the irregular boundaries would be less obvious than circles, would you be able to elaborate on how would I go about randomly offsetting the points?&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Matthew&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MatthewPoppleton_0-1675998612055.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62532iF2DA79253DEC4746/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MatthewPoppleton_0-1675998612055.png" alt="MatthewPoppleton_0-1675998612055.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 03:17:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256857#M65339</guid>
      <dc:creator>MatthewPoppleton</dc:creator>
      <dc:date>2023-02-10T03:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Generate clustered random point data with set number of points</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256985#M65360</link>
      <description>&lt;P&gt;Replace line 50 above with line 2 below (it just stores the result in a variable), move the offset parameters to the rest of the parameters for ease of access.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# randomly distribute the points inside the cluster boundaries
out_fc = arcpy.management.CreateRandomPoints(output_folder, output_name, cluster_boundaries, None, "NumOfPoints", min_point_distance)

# randomly offset each point
min_offset = 0
max_offset = 2000
with arcpy.da.UpdateCursor(out_fc, ["SHAPE@XY"]) as u_cursor:
    for p in u_cursor:
        x, y = p
        dx = random.randint(min_offset, max_offset) * random.sample([-1, 1], 1)[0]
        dy = random.randint(min_offset, max_offset) * random.sample([-1, 1], 1)[0]
        new_p = [x + dx, y + dy]
        u_cursor.updateRow([new_p])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;before:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1676037940002.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62560iD425D3A5132E7432/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1676037940002.png" alt="JohannesLindner_0-1676037940002.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after (with quite high offset values):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1676037967615.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62561i5AF540D76F1FE427/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1676037967615.png" alt="JohannesLindner_1-1676037967615.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 14:10:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1256985#M65360</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-10T14:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Generate clustered random point data with set number of points</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1257006#M65363</link>
      <description>&lt;P&gt;Regarding irregular cluster shapes:&lt;/P&gt;&lt;P&gt;This would be an easy way to generate irregular (but always convex) buffer shapes:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def irregular_buffer(point_geometry, min_dist, max_dist, num_points):
    points = []
    for i in range(num_points):
        angle = random.randint(0, 359)
        dist = random.randint(min_dist, max_dist)
        points.append(point_geometry.pointFromAngleAndDistance(angle, dist).firstPoint)
    multipoint = arcpy.Multipoint(arcpy.Array(points), spatial_reference=point_geometry.spatialReference)
    return multipoint.convexHull()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The num_points argument controls how much the buffer shapes resemble a circle. Higher value -&amp;gt; more circle-like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;num_points = 5:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1676039786502.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62564i0E17440B9ED4FE6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1676039786502.png" alt="JohannesLindner_1-1676039786502.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;num_points = 10:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1676039688946.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62563i532DE915671E231A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1676039688946.png" alt="JohannesLindner_0-1676039688946.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;num_points = 30:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_2-1676039822849.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62565iBF994A35DBC060F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_2-1676039822849.png" alt="JohannesLindner_2-1676039822849.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To use this method, replace lines 41-42 in my original answer with this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;            cluster_buffer = irregular_buffer(cluster_center, min_cluster_radius, max_cluster_radius, 5)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which indeed results in more irregular clusters:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_3-1676040461379.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62569i9B1AC4B21C9E49A8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_3-1676040461379.png" alt="JohannesLindner_3-1676040461379.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And you can still add a random offset at the end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 14:48:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1257006#M65363</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-10T14:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Generate clustered random point data with set number of points</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1257338#M65428</link>
      <description>&lt;P&gt;This is great, thanks again for your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2023 18:01:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/generate-clustered-random-point-data-with-set/m-p/1257338#M65428</guid>
      <dc:creator>MatthewPoppleton</dc:creator>
      <dc:date>2023-02-11T18:01:30Z</dc:date>
    </item>
  </channel>
</rss>

