Generate polygon plot boundaries around random points

2841
11
03-19-2019 02:58 PM
DennisMarks
New Contributor II

Hi,

In past years, I've used the Geospatial Modeling Environment software (with R) to generate rectangular plot boundaries around a set of random points. It was a simple script (below) but it doesn't look like the last GME software is compatible with ArcMap 10.6.  I've seen some older solutions given on these pages but didn't suit this problem, in that I need to input GROUND dimensions (in feet, meters, miles, etc.) and have ArcMap draw rectangle polygons around all points in the layer. I've also seen some Python solutions but used coordinates as input (and I don't know Python). Are there any other possibilities? Does ArcGIS Pro have any feature to do this?

Thank you! 

genshapes(in="C:\randompoints2017.shp", shape="RECTANGLE", dim=c(402.35, 201.175), out="C:\randomplotpolys2017.shp");

0 Kudos
11 Replies
DennisMarks
New Contributor II

FYI: In case someone else wants to create rectangles with specific dimensions as we did (this is for a 1/4 x 1/2 mile rectangle in a NAD83 UTM3N projection), here's what ended up working for us:

>>> import arcpy

... w = 804.7

... h = 402.35

... polygons = []

... dataset = "randompoints2019"

... spatial_ref = arcpy.Describe(dataset).spatialReference

... with arcpy.da.SearchCursor("randompoints2019","SHAPE@",spatial_reference=sr) as cursor:

...      for row in cursor:

...          polygon = arcpy.Polygon(arcpy.Array([arcpy.Point(row[0].centroid.X - w/2,row[0].centroid.Y + h/2),arcpy.Point(row[0].centroid.X - w/2, row[0].centroid.Y - h/2),arcpy.Point(row[0].centroid.X + w/2,row[0].centroid.Y - h/2),arcpy.Point(row[0].centroid.X + w/2,row[0].centroid.Y + h/2)]),sr)

...          polygons.append(polygon)

...

... arcpy.CopyFeatures_management(polygons,r'in_memory\plots')

... 

DanPatterson_Retired
MVP Emeritus

Good to hear you got it figured out Dennis

0 Kudos