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.
-
2Multiply the arcpy by the radius?JC5577– JC55772011年01月28日 01:14:30 +00:00Commented Jan 28, 2011 at 1:14
-
Are you making a distinction between "circle" and "parametric circle"? If so, what is it?whuber– whuber2011年01月28日 03:54:12 +00:00Commented 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.Regan Sarwas– Regan Sarwas2011年01月28日 16:00:39 +00:00Commented Jan 28, 2011 at 16:00
3 Answers 3
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.Regan Sarwas– Regan Sarwas2011年01月28日 16:06:43 +00:00Commented 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.)Dan S.– Dan S.2011年01月29日 20:06:15 +00:00Commented 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.Regan Sarwas– Regan Sarwas2011年01月31日 17:52:14 +00:00Commented 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.Regan Sarwas– Regan Sarwas2011年01月28日 16:12:11 +00:00Commented 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.Regan Sarwas– Regan Sarwas2011年01月31日 17:48:14 +00:00Commented 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).Dan S.– Dan S.2011年01月31日 23:02:42 +00:00Commented 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).Regan Sarwas– Regan Sarwas2011年02月03日 20:37:44 +00:00Commented Feb 3, 2011 at 20:37
-
you might need to use
ang = float(i).....
Stephen Lead– Stephen Lead2014年09月02日 03:02:39 +00:00Commented Sep 2, 2014 at 3:02
Explore related questions
See similar questions with these tags.