I have a set of overlapping polygons and a line of points. A single points can fall within any number of polygons, and I need to determine the attribute values of points that fall within each polygon.

My outlined workflow was:

  1. Select each polygon individually using SelectLayerByAttribute_management
  2. Select the points which fall within that selected polygon using SelectLayerByLocation_management
  3. Iterate through the selected points and extract their attribute values using SearchCursor

The issue I'm running into is that according to this post the polygons for step 1 have to be a "layer" rather than a feature class or shapefile. However for step 2, the polygons cannot be "layers" and have to be a feature class or shapefile.

I was relying on the selection of the polygon features in step 1 and 2 to to be the same. This works inside of ArcMap using the Python console, but I am unable to produce more than the first line.

  • 1
    Both Select commands (#1 and #2) require a Layer as input.
    – klewis
    Commented May 23, 2017 at 21:19
  • Use MakeFeatureLayer to create a layer from a shapefile or GDB feature class
    – Bjorn
    Commented May 23, 2017 at 21:32
  • @Bjorn That's what I was doing. For some reason it wouldn't accept the layer as the third argument in the SelectLayerByLocation. I got it to work by saving the result of MakeFeatureLayer into a variable and then referencing that. The string name of the layer wouldn't work.
    – rovyko
    Commented May 23, 2017 at 21:38
  • 1
    For questions that involve code please always include a code snippet that illustrates what you have tried and where you are stuck, and any error message that results.
    – PolyGeo
    Commented May 23, 2017 at 21:40


Browse other questions tagged or ask your own question.