I am trying to select a point from a point layer that intersect a polyline layers firstpoint and using arcpy. I am getting an error "ExecuteError: ERROR 000622: Failed to execute (Select Layer By Location). Parameters are not valid. ERROR 000623: Invalid value type for parameter select_features."

import arcpy

def main():

    arcpy.env.workspace = r'D:\My Documents\SR91_FeasibilityStudy\GISData\SR-91.gdb'

    arcpy.MakeFeatureLayer_management('Build2035', 'plLayer') #polyline Layer
    arcpy.MakeFeatureLayer_management('Build2035_pts_CollectEvents', 'ptLayer') #point Layer

    with arcpy.da.SearchCursor('plLayer',("Shape@","OID@")) as cursor:
        for row in cursor:
           result = arcpy.GetCount_management('ptLayer')
           print result
  • You can save the first point of each Polyline using "Feature Vertices To Points", enter START as the 3rd parameter. Then intersect the two Point layers.
    – klewis
    Jan 26, 2016 at 22:51

1 Answer 1


If you want to perform a selection for each row, as your script indicates, you need to convert your point object to a geometry object. Here's a very messy line of code that will do so:

arcpy.SelectLayerByLocation_management('ptLayer','intersect',arcpy.Geometry ("point", row[0].firstPoint, arcpy.Describe ('Build2035').spatialReference))

If you want to perform a single selection based off of all first points, create a new feature class and export your first points to it using a cursor (or if you have an advanced license, use Feature Vertices To Points as described by klewis in the comments).

Something like this (untested):

import arcpy

def main():

    arcpy.env.workspace = r'D:\My Documents\SR91_FeasibilityStudy\GISData\SR-91.gdb'
    arcpy.MakeFeatureLayer_management('Build2035_pts_CollectEvents', 'ptLayer') #point Layer

    #Create empty point feature class for first points
    outPath = arcpy.env.workspace
    arcpy.CreateFeatureclass_management (outPath, "FirstPoints", "POINT", spatial_reference = 'Build2035')

    #add firstpoints to feature class
    with arcpy.da.SearchCursor ('Build2035', "SHAPE@") as sCurs:
        with arcpy.da.InsertCursor ("FirstPoints", "SHAPE@") as iCurs:
            for geom, in sCurs:
                row = (geom.firstPoint,)
                iCurs.insertRow (row)

    #select points by first points feature class
    arcpy.SelectLayerByLocation_management('ptLayer','intersect', "FirstPoints")
    result = arcpy.GetCount_management('ptLayer').getOutput (0)
    print result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.