2

This is the data I have: shapefile with polygons shapefile with line features

What I eventually want: line features attributes joined to the polygons that they fall in. I need to clip each polygon with the lines separately.

These are the steps I want to do:

  • select polygon from a shapefile based on a name
  • use this selected polygon to clip several line features
  • then use spatial join to join these clipped lines to the shapefile with all the polygons based on the location
  • apply summary statistics to get lines length summed per polygon

I can do this for one polygon..the question I have is how can I tell the model builder that has to do this whole process for each polygon. So I guess I have to insert an iterator in front of the select by attribute tool..but I don't really understand how. Also, it would be great to get the output in one summary statistic and not in hundred different ones... is that possible?

thanks so much sandra

2
  • 1
    It may be worth including a diagram showing what you are trying to achieve. My first question would be: when a polygon has more than one line passing through it which line do you choose as the one whose attributes will get transferred to it? Or are you really trying to join polygon attributes onto any lines that pass through them? The latter may be very easy (if your polygons have no overlap between themselves) using the Intersect tool.
    – PolyGeo
    Commented Oct 23, 2012 at 23:34
  • What I want to achieve is indeed the simple task that you described, I want to assign all the lines that fall into the polygon to the polygon. I tried intersect first, the problem though is that the lines that fall in more than one polygons (e.g. overlap the boundaries) are not assigned or assigned to the wrong polygon. So when I use the clip feature it splits those lines at the polygon's boundaries.
    – sandra
    Commented Oct 23, 2012 at 23:42

2 Answers 2

2

The attached model intersects the lines and polygons and creates a multipart featureclass (i.e. all of the line segments contained within a polygon combine). Make sure to select the correct dissolve feature in the Dissolve tool and select the "Create multipart features" checkbox. Also, make sure the output is located in a geodatabase because the line lengths per polygon will be automatically calculated for you.

enter image description here enter image description here

4
  • thank you so much for your answer. That would work but if I use the dissolve tool I lose all the attributes of the individual line segments, which I would like to keep as I need them to summarize one of their attribute per polygon..
    – sandra
    Commented Oct 25, 2012 at 20:15
  • No problem, just drop the dissolve and query/summarize the attributes.
    – Aaron
    Commented Oct 25, 2012 at 22:09
  • where is the "attached" model? Commented Jul 19, 2021 at 19:10
  • @mattwilke The attached model is the screenshot with the blue, orange, and green shapes.
    – Aaron
    Commented Jul 19, 2021 at 19:43
1

Before going to this trouble have you looked at whether using Joins and Relates > Joins ... from the context menu of your Polys layer may not give you the result you are after in one step?

enter image description here

2
  • I believe this method sums the entire line length inside and outside of the polygon features rather than the OP's required "lines length summed per polygon".
    – Aaron
    Commented Oct 24, 2012 at 1:43
  • Doing an Intersect (my first suggestion) to chop the lines up before the spatial join should get around that - but your Answer looks like a good one so I have upvoted it.
    – PolyGeo
    Commented Oct 24, 2012 at 1:48

Your Answer

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

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