Selecting Polygons Overlayed by Polylines

5920
13
Jump to solution
02-11-2018 04:47 PM
JoshuaBrengel
New Contributor III

Hello,

I'm trying to select polygons from a feature class using a polyline feature class. 

See below for an example that shows the type of feature class/general concept I'm dealing with:

I don't want to have all three polygons selected, just the two with the blue dots.   My end goal is to export the selected polygons so that I can merge them into a one large polygon. 

It doesn't seem like there is a Select By Location method that can isolate the polygons I'm interested in (again, the two that contain dblue dots).  I tried "Append" on the two feature classes (first had to convert polygons to lines) and then used "Trim Line".  That worked to get rid of the dangle, but I couldn't get a line feature back that could be used for the purpose I wanted in Select By Location.

Also, I tried Integrate to change the line to get it inside just the two Polygons of interest (so I could then use it to select the two polygons instead of having all three polygons selected), but that was a bit too messy for the actual feature classes I have. In other words, the line feature didn't modify in predictable way that would be helpful to use it in Select By Location.

Thanks for your help,

- Josh

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

For my intersect option, then you would want to select the line segments that have both segments endpoints in them

The pictures here http://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-by-location-graphical-example...

http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/select-by-location-graphica...

will pretty rule out a lot of options but this might be the key since the dangle segment doesn't reach the other side.

CROSSED_BY_THE_OUTLINE_OFThe features in the join features will be matched if a target feature is crossed by their outline. The join and target features must be lines or polygons. If polygons are used for the join or target features, the polygon's boundary (line) will be used. Lines that cross at a point will be matched, not lines that share a line segment.

View solution in original post

13 Replies
DanPatterson_Retired
MVP Emeritus

Did you try Intersect...

Intersect the polylines with the polygon, and select a polyline as output.  Your polyline should be divided into 3 pieces, two of which will be the ones that you want to use with a select by location, selecting the polylines that are nearest to the points..  If you have an advanced license, the Near tool might help, or even a spatial join of the segmented polylines to the points

ChrisDonohue__GISP
MVP Alum

Another way to solve this is to use two Select By Locations.  For example, one could use Select By Location to find the parcels crossed by the lines, then save that selection out as a new feature class, then run the second Select By Location comparing the output from the first one to the points.

Using Select By Location—Help | ArcGIS for Desktop 

Chris Donohue, GISP

JoshuaBrengel
New Contributor III

Hi Chris and Dan.  By drawing the two blue dots, I think I misled you both with my actual problem.  My apologies.   

The two blue dots are not actual point features in ArcMap.  They are just dots I drew in with Windows' Snipping Tool to distinguish the polygons that I'd like to be selected.   Basically, I just want to end up selecting the two polygons marked by the blue dots, as these two polygons will represent a watershed around the stream feature (i.e. polyline feature). 

The third polygon that has no blue dot and has the dangle should not be selected.  The dangle exists because my polyline and polygon data are not the same accuracy, which prevents me from nicely selecting the polygons that intersect the polylines.   I would then export these polygons and dissolve them to have a final watershed around the stream of interest. 

Again, I'm sorry about the confusion and hopefully, that clears things up.  Thank you!

0 Kudos
DanPatterson_Retired
MVP Emeritus

For my intersect option, then you would want to select the line segments that have both segments endpoints in them

The pictures here http://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-by-location-graphical-example...

http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/select-by-location-graphica...

will pretty rule out a lot of options but this might be the key since the dangle segment doesn't reach the other side.

CROSSED_BY_THE_OUTLINE_OFThe features in the join features will be matched if a target feature is crossed by their outline. The join and target features must be lines or polygons. If polygons are used for the join or target features, the polygon's boundary (line) will be used. Lines that cross at a point will be matched, not lines that share a line segment.

XanderBakker
Esri Esteemed Contributor

Depending on the precision of your data you could accomplish this by doing several steps. You could create a point featureclass from the line, creating points for "BOTH_ENDS":

And apply a small buffer to those points to make sure that we can distinguish the end points that area really located within a polygon and not on the outline.

The first step would be to select those polygons where the lines intersect the polygons:

This will select all 3 polygons. Then you will remove polygons from the selection that completely contain the buffered end points:

To end up with this:

You could also use some python code and intersect each polygon outline with the line and count the resulting points (2 gets selected and 1 not). 

XanderBakker
Esri Esteemed Contributor

As an example snippet how this could be done in Python:

def main():
    import arcpy

    fc_poly = r'C:\GeoNet\SelectPolygonByLine\data.gdb\polygons'
    fc_line = r'C:\GeoNet\SelectPolygonByLine\data.gdb\line'

    polyline = arcpy.da.SearchCursor(fc_line, ('SHAPE@')).next()[0]

    fid_set = []
    with arcpy.da.SearchCursor(fc_poly, ('SHAPE@', 'OID@')) as curs:
        for row in curs:
            polygon = row[0]
            oid = row[1]
            outline = polygon.boundary
            result = polygon.intersect(polyline, 1)
            if len(result) == 2:
                fid_set.append(oid)

    fld_oid = arcpy.Describe(fc_poly).OIDFieldname
    where = '{0} IN ({1})'.format(arcpy.AddFieldDelimiters(fc_poly, fld_oid), ', '.join(str(a) for a in fid_set))
    print where

if __name__ == '__main__':
    main()

When using this situation (label of polygon is OBJECTID):

This will yield a where like:

OBJECTID IN (1, 2)

When I apply this to the polygon layer, you get this result:

But all depends on the precision of the data...

JoshuaBrengel
New Contributor III

Thanks for your help and creative idea Dan.  I tried your suggestion but I did not get the results I wanted unfortunately.  I think I oversimplified my features in the drawing.  Essentially, there are cases in which dangles represent actual features (in other words, there are features that don't completely cross the polygons that I need to keep). 

Here are two examples of actual data I'm looking at:

1) I want to select and keep the polygons with a red X.  Polygons with a blue X will be incorrectly selected using my current methodology, since the polyline and polygon precision is different:

2) Here's an example of a dangle I'd like to use to actually select an underlying polygon.  I want to keep all polygons in this picture but to make it easier to distinguish, I put a Red X in the polygon with the dangle:

 

Does that give you a better idea of what I'd like to accomplish?   In any case, it's a fun problem!

Thanks again,

- Josh

0 Kudos
XanderBakker
Esri Esteemed Contributor

Is there a logic in the procedure? Like a minimum length that a line should cross the polygon to be included in the selection?

0 Kudos
JoshuaBrengel
New Contributor III

Hi Xander.  Unfortunately, the length of the lines, in theory, could be of all different lengths.  As a general rule, they would be pretty short though, sort of like the small lengths of lines that pass through the polygons with the blue X in the first picture above.  Using a minimum length somehow might be a good way to approach it though, since the dataset is relatively small I'm dealing with and miss polygons could be added manually.

0 Kudos