Artificial Intelligence
Please fill the required field.

tool in toolbox to find random two point in perimeter of a polygon according to distance in arcmap


In ArcMap, if you want to randomly select two points along the perimeter of a polygon, you can follow a process that combines several tools and methods. The basic steps involve calculating the perimeter, generating random distances, and then finding coordinates based on those distances. Here’s how to do it step by step: ### Step-by-Step Guide 1. **Calculate the Perimeter**: - Use the **Geometry Calculator** to calculate the perimeter of your polygon feature class. - You can use the `Calculate Geometry` feature in the attribute table to add a new field that stores the perimeter length. 2. **Generate Random Distances**: - Use the **Random Number Generator** to generate two random distances between 0 and the calculated perimeter. - You can do this in Excel, Python, or directly in ArcMap using the field calculator with a random function. 3. **Create Points Along the Perimeter**: - Use the **Generate Points Along Lines** tool if you have a polyline representation of the perimeter. - Convert your polygon to a polyline if necessary. You can do this using the **Polygon to Line** tool. - Use the **Generate Points Along Lines** tool to create points along the polyline at specified distances. 4. **Select Random Points**: - After generating points along the perimeter, you can query or randomly pick two points from the created set of points. - Use the **Select by Attributes** or a combination of the **Calculate Geometry** and selection processes to achieve this. 5. **Extract Coordinates**: - Once you have selected your two random points, you can extract their coordinates or other attributes as needed. ### Example Using Python Script If you prefer a more automated approach, you can use a Python script with ArcPy: ```python import arcpy import random # Set your polygon feature class polygon_fc = r"Path\To\Your\Polygon.shp" # Calculate perimeter with arcpy.da.SearchCursor(polygon_fc, ['SHAPE@']) as cursor: for row in cursor: perimeter = row[0].length # Generate two random distances random_distance_1 = random.uniform(0, perimeter) random_distance_2 = random.uniform(0, perimeter) # Create the polyline from the polygon polyline_fc = "in_memory/polyline" arcpy.PolygonToLine_management(polygon_fc, polyline_fc) # Generate points along the polyline points_fc = "in_memory/points" arcpy.CreateFeatureclass_management("in_memory", "points", "POINT") arcpy.GeneratePointsAlongLines(polyline_fc, points_fc, "PERCENTAGES", distance=random_distance_1) # Repeat for the second random distance arcpy.GeneratePointsAlongLines(polyline_fc, points_fc, "PERCENTAGES", distance=random_distance_2) # Now points_fc contains points at random distances along the perimeter ``` ### Important Note: - Make sure to handle the random selection accordingly, checking that the two random distances are not the same. - The above steps assume you're familiar with ArcGIS tools and the Python scripting environment. Adjust paths and parameters as necessary for your specific dataset and environment. This workflow should allow you to randomly select two points on the perimeter of a polygon according to the distance in ArcMap.