# Select by Location - Cross more than one Side

###
#1
Posted 07 December 2010 - 01:43 PM

I'm trying to come up with a way to select lines from a shapefile in ArcGIS 10 that transect a polygon. The built-in Select by Location tools allow for, at best, intersections or crossings (which means crossing at at least one location). I need to select lines that cross polygons at at least two locations.

Is it possible to modify the select by location tool using Python? Or would it be simpler to write my own script (and if so... any links on where to begin? My Python skills are a bit basic.)

Or, has anyone already solved this problem and can offer some sound advice?

What I'm trying to accomplish is to identify the minimum elevations from a series of contours that cross all the way through a large set of study areas delineated by polygons.

-Thanks

###
#2
Posted 07 December 2010 - 02:00 PM

Can you just stack your selections? Select the first set of intersections then select from that select-set for the second intersection?

GIS Reference and Instruction Specialist, Stanford Geospatial Center.

www.mapbliss.com

@mapbliss

###
#3
Posted 07 December 2010 - 02:22 PM

I have a long stretch of coast that I've completely segmented into many rectangular-ish sections. I have contour lines for that coast and I want to select only the lines that run all the way through at least one polygon (think barriers). In the attached image you'll see a portion of my study area (beige polygons) and contour lines (blue lines). I want to remove all those little contour lines that touch only one side or no sides. I can whittle down the numbers by removing contours of a minute size, and then selecting from the remaining contours those that do not touch any edges and removing those. That's a decent work-around, but it doesn't solve my problem entirely. I figure that there has to be a real solution to this dilemma.

Conversely it would be acceptable to select polygons that are completely crossed by a contour line. I could work with that, but then there's the same problem. How do you select polygons that are intersected on at least two sides by a line?

-Thanks

You need to select lines that intersect two polygons or lines that intersect a single polygon twice? There must be a way to construct this as a simple query without writing a script.

Can you just stack your selections? Select the first set of intersections then select from that select-set for the second intersection?

#### Attached Files

**Edited by Archmap, 07 December 2010 - 02:34 PM.**

###
#4
Posted 08 December 2010 - 08:03 AM

###
#5
Posted 08 December 2010 - 04:48 PM

Clip the contour lines to the polygons.

Use the 'Features to Vertices' tool on these new line segments and specify that you want BOTH ENDS.

Use 'Add XY Coordinates' tool to add coordinate values to this point file.

Perform 'Summary Statistics' on the point file table, where your statistic is a RANGE of the 'X Value' using the line segment ID as your Case Field.

You can join this table back to your line segment file and select only the segments that have a RANGE value that is the equivalent (or within a select tolerance) of your polygon widths.

Of course, this will only work if your polygons are rectangles of equal width, but even if they are slightly irregular or of varying widths, you could perform some xy calculations on the polygons to get the shortest and longest 'X' widths for each polygon and spatially join your line segments to the polygons and select by line segments whose 'RANGE' values fall within the the tolerance of shortest and longest 'X' widths for each polygon.

I haven't actually done this exact analysis before, but it seems that theoretically it should work.

Good luck,

Heath

###
#6
Posted 09 December 2010 - 09:56 AM

I'll give this a try and post back if I get it to work.

Thanks again.

-Richard

I assume that you are really only concerned with contour lines that cross the width of each polygon (as opposed to contour lines that loop back and intersect the same line segment). It also appears that your polygons are all of an even width (or at least very close to it). If those are both true, then you could try something like this:

Clip the contour lines to the polygons.

Use the 'Features to Vertices' tool on these new line segments and specify that you want BOTH ENDS.

Use 'Add XY Coordinates' tool to add coordinate values to this point file.

Perform 'Summary Statistics' on the point file table, where your statistic is a RANGE of the 'X Value' using the line segment ID as your Case Field.

You can join this table back to your line segment file and select only the segments that have a RANGE value that is the equivalent (or within a select tolerance) of your polygon widths.

Of course, this will only work if your polygons are rectangles of equal width, but even if they are slightly irregular or of varying widths, you could perform some xy calculations on the polygons to get the shortest and longest 'X' widths for each polygon and spatially join your line segments to the polygons and select by line segments whose 'RANGE' values fall within the the tolerance of shortest and longest 'X' widths for each polygon.

I haven't actually done this exact analysis before, but it seems that theoretically it should work.

Good luck,

Heath

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users