5

I'm trying to write a python script with ArcPy that draws arcs and I've achieved something with creating a buffer and then clipping it with a bounding box so I only keep the length I need (I thought it was easier that way than calculating from my center point and radius, vertex by vertex from my start angle to my end angle). The problem is that the buffer too creates polygon buffers and since I only have ArcVIew (soon ArcEditor) and I can't use the polygon to line tool (licenced to ArcInfo).

Is there a way to convert a polygon to a polyline somehow with ArcPy or create directly a polyline buffer?

1
  • 2
    What is your end goal? Are you really just trying to create polylines that are offset (displaced) from the original polylines by a specific distance? Apr 30, 2012 at 19:51

2 Answers 2

3

You could go about this in a few ways. One way to do it without Zero_Qualms' suggestion of ET_GeoWizards and with only an ArcView licence is to create your buffer polygons just as you have done. Then iterate over the buffer polygons, pulling out their geometry and build a new feature class using the geometry but cast it as a polyline instead. See these sections of the documentation to help you (if needed) with reading and writing geometries in ArcPy (scroll down for examples).

The alternative is to write a script to create the line without creating a buffer to copy first. You will need to read the geometries of your lines and progress from point to point, calculating the bearing at each step and then calculating the offset location of your buffer-line. This should be straightforward with a bit of basic vector maths and trig. You can calculate bother the left and right side of the line at the same time. You just need to ensure that the right-side (assuming a clockwise winding) points are added to your polyline so they are in sequential order following the entire set of left-hand points and in the reverse direction. You could do this by having two lists of points and then reverse the order of your right-hand point list before appending it to the lefthand points list to make your line.

7
  • That's where I'm heading now. I used Shapely and OGR because that's what was in the example I had. The only thing is that shapely's buffer don't have enough points to create its circle, but I'll find something. Thanks!
    – fgcarto
    May 3, 2012 at 17:37
  • 1
    The Shapely buffer takes the form: object.buffer(distance, resolution=16). The second parameter (resolution) is usually omitted and defaults to 16 segments. If you want something that approximates more closely to a circle, increase the resolution setting (say to 32). May 3, 2012 at 19:54
  • Any idea how to reverse the order of my point? I tried to use a simple python feature (reversed()) to reverse my iterator, but it still start from my first point and then backward. In can't access directly (or haven't found a way) a point in my linestring (as in line(i) or line[i]), so I can't read for the end to rewrite my line... I
    – fgcarto
    May 8, 2012 at 14:05
  • Unfortunately, ArcPy's cursors go in one direction only. You have a couple of options. One would be to read all your points into a list first and then use the reversed() function on that list. The other would be to use OGR, which would give you access to all the geometry in one go (but you may prefer to stick just with arcpy). May 9, 2012 at 9:41
  • I've step out of ArcPy a little, since I'm working in the train in the morning and don't have ArcGIS on my laptop. I had problem with point order so I will do what you suggested in your first answer and calculate point by point the construction of my line. That way, I'll be able to create counterclockwise and clockwise line... I hope! ;)
    – fgcarto
    May 9, 2012 at 13:43
3

One of the free functions in the ET_GeoWizards addon for ArcGIS supposedly has the ability to convert Polygons to Polylines:

http://www.ian-ko.com/ET_GeoWizards/gw_NoRestrictions.htm

Download section at:

http://www.ian-ko.com/

2
  • 1
    Thanks. I should have mentionned that it will be put in a batch script to create a couple hundred arcs. Ideally, it would need to all be executed from the script (I don't think I can access GeoWizard tools that way?).
    – fgcarto
    Apr 30, 2012 at 19:26
  • 1
    No worries, check out this post, apparently you can use GeoWizard tools in Python and commandline: gis.stackexchange.com/questions/19728/… Apr 30, 2012 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.