# How to create a circle in arcpy

Suppose I have a dataset where each record has an x,y and r (the centroid and radius of a circle). How can I create a polygon feature class containing parametric circles?

Sorry to those who have a great open source solution, but I'm stuck using python in ArcGIS 10.

• Multiply the arcpy by the radius? Commented Jan 28, 2011 at 1:14
• Are you making a distinction between "circle" and "parametric circle"? If so, what is it? Commented Jan 28, 2011 at 3:54
• @whuber - I wanted to be clear I am not looking for what use to pass for a circle in ArcMap (an n sided polygon approximation) like the answer by Dan S. Commented Jan 28, 2011 at 16:00

You could create a buffer around the point using the buffer command. For example in 10.0 using arcpy.Buffer_analysis() (see ArcGIS help), and use the radius as the buffer distance.

• I tried this but circle = arcpy.buffer(center_point, empty_geom, r) is 1000x more expensive than poly = arcpy.Polygon(arcpy.array([pt1,pt2, ...]). If you inspect the circle that comes back from buffer command you can see it is a polygon with two points, both at the top of the circle. I wonder if there is a way to create the circle with the arcy.polygon command. Commented Jan 28, 2011 at 16:06
• @Regan -- I peeked at the documentation for arcpy.Polygon and it looks like it'd be easy to work w/ my code below: arcpy.Polygon(arcpy.array([ [px,py] for (px,py) in circle_poly(center_point.x,center_point.y,r) ])). (Note this is a polygon with 100 straight-line sides approximating a circle, not an actual circle. Tweak accordingly.) Commented Jan 29, 2011 at 20:06
• @Dan, Thanks. I posted a timing comparison as a comment on your answer. and your solution is faster. Unfortunately my user has an allergy to all those vertices. Commented Jan 31, 2011 at 17:52

You could throw together a model to do this in ArcMap. First create an XY layer from your table to get a point feature class, then run buffer on it against the radius field.

• I like this, it may not be the fastest solution (I'm still hoping for an answer to my comment on Celenius' answer), but will be simpler to maintain than writing my own script. Commented Jan 28, 2011 at 16:12

The other answers are probably better for your environment, but there's no need to fear a tiny bit of trig, and something like below will work equally well in all (python) environments.

import math
def circle_poly(x,y,r):
for i in range(100):
ang = i/100 * math.pi * 2
yield (x + r * math.cos(ang), y + r * math.sin(ang) )

(However, you may have cause to fear the arcpy API required to assemble polygon objects from point data. I haven't had to tackle it yet. :)

You may find this question/my answer interesting if you need circle to truly represent equal distances around the point.

• I timed this against the buffer solution, and with 50 sides (I think this is what ESRI uses for a default), this solution is 15 times faster, although it does consume considerably more storage space. I don't know which draws faster. Commented Jan 31, 2011 at 17:48
• @Regan -- I'm glad it worked, at least! ;) I'd be curious to see if there's any difference in storage space if both are converted to a shapefile (which, unless I'm wrong, will force a conversion of any curves into straight lines). Commented Jan 31, 2011 at 23:02
• you were right, exporting to shapefile creates a 70 sided polygon, but it is only about 5x the storage space of a file geodatabase feature class (as reported by ArcCatalog). Commented Feb 3, 2011 at 20:37
• you might need to use ang = float(i)..... Commented Sep 2, 2014 at 3:02