<?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: Dispersing geocoded points within a Polygon in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/dispersing-geocoded-points-within-a-polygon/m-p/608380#M34261</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To visualize what I would like to achieve:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The geocoding result (with only one ZIP/normally I have around 500):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29401[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And the result I would like to receive:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29402[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Nov 2013 11:26:15 GMT</pubDate>
    <dc:creator>MTP</dc:creator>
    <dc:date>2013-11-27T11:26:15Z</dc:date>
    <item>
      <title>Dispersing geocoded points within a Polygon</title>
      <link>https://community.esri.com/t5/data-management-questions/dispersing-geocoded-points-within-a-polygon/m-p/608379#M34260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a problem with dispersing geocoded points (randomely/)equally within a polygon. More specific I have geocoded adresses using zip codes and would like to disperse them within a polygon. I know that it is possible to disperse markers but I would like to disperse the points. Dispersing them randomely would be not a problem as it is i.e. possible with Geowizard.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore, i have searched the forums and have found some solutions for Avenue but in my ArcGIS 10 this obviously is not working. Based on the post here: &lt;/SPAN&gt;&lt;A href="http://arcpy.wordpress.com/2013/06/07/disperse-overlapping-points/#comment-220" rel="nofollow noopener noreferrer" target="_blank"&gt;http://arcpy.wordpress.com/2013/06/07/disperse-overlapping-points/#comment-220 &lt;/A&gt;&lt;SPAN&gt; I have tried to develop a script. But it is not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone advice what could be changed to make it work? Is it necessary to have the x, y already in the tael definded as columns?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import random
import arcpy

arcpy.env.workspace = �??D:\�?�\database.gdb�?�

in_points = �??D:\�?�\�?�\geodatabase.gdb\Geocoding_Results.shp�?�
polygon = �??D:\�?�\geodatabase.gdb\zipcode.shp�?�

def point_in_poly(poly, x, y):
�??�?�"Returns if the point is inside the polygon.

Parameters:
poly: arcpy.Polygon() geometry
x: x coordinate (float)
y: y coordinate (float)

�??�?�"
pg = arcpy.PointGeometry(arcpy.Point(x, y), poly.spatialReference)
return poly.contains(pg)

def disperse_points(in_points, polygon):
�??�?�"Randomly disperse points inside a polygon.

Parameters:
in_points: Point feature class/layer (with or without selection)
polygon: arcpy.Polygon() geometry

�??�?�"

lenx = polygon.extent.width
leny = polygon.extent.height

with arcpy.da.UpdateCursor(in_points, "shape@xy") as points:
for p in points:
x = (random.random() * lenx) + polygon.extent.XMin
y = (random.random() * leny) + polygon.extent.YMin
inside = point_in_poly(polygon, x, y)
while not inside:
x = (random.random() * lenx) + polygon.extent.XMin
y = (random.random() * leny) + polygon.extent.YMin
inside = point_in_poly(polygon, x, y)
points.updateRow([(x, y)])&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:02:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/dispersing-geocoded-points-within-a-polygon/m-p/608379#M34260</guid>
      <dc:creator>MTP</dc:creator>
      <dc:date>2021-12-12T02:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dispersing geocoded points within a Polygon</title>
      <link>https://community.esri.com/t5/data-management-questions/dispersing-geocoded-points-within-a-polygon/m-p/608380#M34261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To visualize what I would like to achieve:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The geocoding result (with only one ZIP/normally I have around 500):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29401[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And the result I would like to receive:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29402[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 11:26:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/dispersing-geocoded-points-within-a-polygon/m-p/608380#M34261</guid>
      <dc:creator>MTP</dc:creator>
      <dc:date>2013-11-27T11:26:15Z</dc:date>
    </item>
  </channel>
</rss>

