7

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.

Regan Sarwas
  • 1,675
  • 11
  • 20

3 Answers3

4

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.

djq
  • 16,297
  • 31
  • 110
  • 182
  • 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. – Regan Sarwas Jan 28 '11 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.) – Dan S. Jan 29 '11 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. – Regan Sarwas Jan 31 '11 at 17:52
3

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.

Jason Scheirer
  • 18,002
  • 2
  • 53
  • 72
  • 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. – Regan Sarwas Jan 28 '11 at 16:12
3

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.

Dan S.
  • 3,549
  • 17
  • 20
  • 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. – Regan Sarwas Jan 31 '11 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). – Dan S. Jan 31 '11 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). – Regan Sarwas Feb 03 '11 at 20:37
  • you might need to use ang = float(i)..... – Stephen Lead Sep 02 '14 at 03:02