I have 2 separate feature classes, line and point. I want to select line feature class based on the location of points on a point feature class. If the points are on the line itself then I don't want to select the line. But, if they are at its end/start, the line should be selected.

  • You can export the Line endpoints to a Point featureclass - "Feature Vertices to Points", select Point type = "END". Use this in your select by location, join the results back to the lines on Objectid or Fid.
    – klewis
    Commented Dec 12, 2016 at 18:26
  • Assign point IDs to line, using something like gis.stackexchange.com/questions/125090/…
    – FelixIP
    Commented Dec 12, 2016 at 18:36
  • I already have a points feature class. I need to select the lines based on that point feature class. I did what you said, it will select all the lines as all the lines now have points at its ends (got using "Feature Vertices to points")
    – pnkjmndhl
    Commented Dec 12, 2016 at 18:36
  • You need to @ user name, otherwise you are messaging to a void
    – FelixIP
    Commented Dec 12, 2016 at 19:11
  • You completely misunderstood what @klewis suggesting. Perhaps read again
    – FelixIP
    Commented Dec 12, 2016 at 19:18

3 Answers 3


I suggest these steps to Select Lines that Intersect another Point FC only at Line End Points.

Export the Line endpoints to a Point featureclass (named Line_endpoints) - "Feature Vertices to Points", select Point type = "END".

Select By Location, Line_endpoints with Point_FC, Intersect. You can add a small Search Tolerance if needed (if Points don't match exactly)

Select By Location, Line FC with Line_endpoints, Intersect, click Use Select features

  • +1 I posted explanation of your solution and saw your answer. oops
    – FelixIP
    Commented Dec 12, 2016 at 22:28
  • @FelixIP, no problem. Your answer is more descriptive with graphics.
    – klewis
    Commented Dec 12, 2016 at 22:30

If I understand your question correctly, you can solve this by using arcpy.da.SearchCursor on your point feature class and load the point geometry into a list. In a arcpy.da.SearchCursor the geometry object can be accessed via the SHAPE@ token. Something like this:

point_feature_class = r'C:\path_to_data\points.shp'
points = []
with arcpy.da.SearchCursor(point_feature_class, "SHAPE@") as s_cur:
    for row in s_cur:

Then you can again use an arcpy.da.SearchCursor to loop over the line features and compare the first and last points of the lines to the points within the list you created above. Something like this:

line_feature_class = r'C:\path_to_data\lines.shp'
lines_to_select = []
with arcpy.da.SearchCursor(line_feature_class, ['OID@', 'SHAPE@"]) as s_cur:
    for row in s_cur:
        first_point = row[1].firstPoint
        last_point = row[1].lastPoint
        for pt in points:
            if pt == first_point or pt == last_point:

This will give you a list of OID of lines that have points from the point feature class that are either the first or last point. You can then use the OID values within your list in many or one complex arcpy.SelectLayerByAttribute_management.

This is off the top of my head and is a fairly roundabout way to get this done, but it should get the job done and/or get you going in the right direction. One note about this method is because you are comparing geometries, you need to make sure that that both feature classes have or don't have Z and M values. If one does and the other does not then this process should be modified to just compare the XY values either through straight comparisons or creating new more simple point geometries of just XY. There is certainly room for improvements and simplifications of this process.

  • 1
    Your line_feature_class is the same shapefile as the `point_feature_class'. I don't think you meant to do that.
    – Fezter
    Commented Dec 12, 2016 at 21:56
  • @Fezter thanks for the heads up, I made the corrections. Copy and paste is not always the best when quickly coding...
    – GeoSharp
    Commented Dec 12, 2016 at 21:58
  • 1
    I strongly believe that scripting should be your last resource, esp. for tasks that unlikely to be repeated
    – FelixIP
    Commented Dec 12, 2016 at 22:27
  • @FelixIP personal preference. Many tools to solve problems in GIS. For someone with the skill set I would go the other route as scripts can be automated if the task is repeated often. But I see your point :-)
    – GeoSharp
    Commented Dec 12, 2016 at 22:43

This is what @klewis suggesting:

enter image description here

arcpy.FeatureVerticesToPoints_management("LINES", "D:/Scratch/ends.shp", " BOTH_ENDS ")
arcpy.SelectLayerByLocation_management("ends", "INTERSECT", "POINTS")
arcpy.SelectLayerByAttribute_management("ends", "SWITCH_SELECTION")
arcpy.AddJoin_management("LINES", "FID", "ends", "ORIG_FID", "KEEP_ALL")
arcpy.SelectLayerByAttribute_management("LINES", "NEW_SELECTION", """"ends.ORIG_FID" IS NOT NULL""")

enter image description here

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.