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.

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

share|improve this question
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 Oct 23 '12 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 Oct 23 '12 at 23:42

2 Answers 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

share|improve this answer
    
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 Oct 25 '12 at 20:15
    
No problem, just drop the dissolve and query/summarize the attributes. –  Aaron Oct 25 '12 at 22:09

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

share|improve this answer
    
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 Oct 24 '12 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 Oct 24 '12 at 1:48

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.