Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

Thanks!

share|improve this question
1  
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? –  RyanDalton Apr 30 '12 at 19:51
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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! –  fgcartographix May 3 '12 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). –  MappaGnosis May 3 '12 at 19:54
    
Didn't know that one. Thanks!! –  fgcartographix May 4 '12 at 15:07
    
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 –  fgcartographix May 8 '12 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). –  MappaGnosis May 9 '12 at 9:41
show 3 more comments

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/

share|improve this answer
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?). –  fgcartographix Apr 30 '12 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/… –  Loxodrome Apr 30 '12 at 20:04
    
Really? Nice! Thanks! –  fgcartographix May 1 '12 at 19:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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