how to: constructing polygon boundary with circular arc segments

3226
8
07-29-2016 12:29 AM
BernhardEhrminger
New Contributor III

dear group members

I know how to construct polygons with linear boundary segments.

So here is a short python expample:

array = arcpy.Array()

coordinates=['some data']

for coordinate in coordinates:

    array.add(arcpy.Point(coordinate[0], coordinate[1]))

array.add(array.getObject(0))  #close polygon

polygon = arcpy.Polygon(array)

please, is there some advice on how to construct a polygon boundary with circular arc segments alternating with linear segments using python & arcpy?

thank you

0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

arcobjects http://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#icirculararc.htm

no mention of python here Changing a segment into a straight line, a circular arc, or a Bézier curve—Help | ArcGIS for Desktop

nor is there an arc geometry objec Geometry—Help | ArcGIS for Desktop

perhaps if you could elaborate on what you are trying to do, then a solution might be at hand.  Circular arcs can be replaced by densified line segments and would suit most situations unless you are trying to replace CAD functionality

BernhardEhrminger
New Contributor III

Dan, thank you for your reply.

I am searching for a technique for importing geographic data form ASCII files. In those data sets, circular arcs are described by three points on the arc.

0 Kudos
DanPatterson_Retired
MVP Emeritus

I am familiar with how circular arcs, I am just saying there is no built in way to generate an arc using builtin python for use in ArcMap. If you examine the arcpy interface you will see there is no arc class... you can connect the dots at worst or generate a multisegmented polyline, but if you intent is to generate a true arc, then you should look at arcobjects

BernhardEhrminger
New Contributor III

Dan, thank you again.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Dan is right, no objects in arcpy to construct these. There is a possible solution provided here: arcgis - drawing a circular arc using arcpy - Stack Overflow . It uses arcpy.XYToLine_management: XY To Line—Help | ArcGIS for Desktop

BruceHarold
Esri Regular Contributor

Ah the old arc-through-three-points problem.

In the attached is a script that has the math, you'll need to figure out how to clip the part of the circle you want.

Regards

JoshuaBixby
MVP Esteemed Contributor

The ArcPy Geometry classes support curves, at least the internal data structures do.  Unfortunately, none of their constructors support curves, and several of their properties also don't work well with curves.  The following StackExchange thread demonstrates a way to do it:  Can ArcPy 10.1 be used to generate true curve elliptical polygons in a file geodatabase?  Basically, you use Esri JSON and arcpy.AsShape to create the geometry:

>>> esri_json = {
...     "curvePaths": [[
...         [1,5],
...         {"c": [[7,3], [6,2]]}
...     ]],
...     "spatialReference": {"wkid": 0}
... }
... 
>>> ln = arcpy.AsShape(esri_json, True)
>>> arcpy.CopyFeatures_management(ln, 'in_memory/tmpFC')
<Result 'in_memory\\tmpFC'>
>>>

circularstring_example.PNG

If you are going to take this approach, I encourage you to read the Geometry objects section of the ArcGIS REST API.  The Geometry objects section explains the syntax for working with the various curved objects.  Also, always define a spatial reference with the Esri json because not doing so causes some really strange behaviors with the geometry objects that are created.

BernhardEhrminger
New Contributor III

this is very interesting and helpful. thank you Joshua

0 Kudos