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 have two layers : a line layer (red) and a polygon layer (green).

enter image description here

I would like to select the lines which 60% are contained in the polygon.

How can I do that?

Until now, I used "select by location" with the "have their centroid in" method, but in some cases, this method is no longer appropriated.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Here is a simple approach:

Add a field to your attributes that stores the length of the lines. Then clip the lines with the polygons. Finally select the lines whose new length is greater than or equal to the original length * 0.6. This gives you a set of Line IDs to select from in your original (un-clipped) layer.

You can do this as a multistage process, perhaps in Model builder and discard the intermediary data, or possibly as a nested SQL query if your data are in a suitable database.

share|improve this answer
    
Thanks a lot ! I just tested and it works well. I will make a python tool with in input the two layers, the ID field of the lines, the percentage. –  superrache Feb 26 at 11:10
    
I like this approach. If you happen to use R, then the pracma and sp packages have tools to determine what's inside (or not) a polygon and related tricks. –  Carl Witthoft Feb 26 at 17:53

there's a number of steps needed to achieve this:

1 - Make a copy of the line dataset

2 - Create 2 fields in your line dataset and do a "calculate geometry" to calculate the length of each line in one of these fields, and add a unique name or number to each line in the other field.

3 - cut each line where it intersects a polygon.

4 - Add another field to the line dataset and calculate the new length.

5 - Now you have the old length and the new length, so you will be able to calculate which lines have 60% inside the polygons. Select them.

6 - Export these selected lines (which will be segments of the original lines). You can now do a spatial selection on your copy of the line dataset (the copy you made in step 1) to select the full lines.

share|improve this answer

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.