1

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.

closed as off-topic by PolyGeo May 23 '17 at 21:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Both Select commands (#1 and #2) require a Layer as input. – klewis May 23 '17 at 21:19
  • Use MakeFeatureLayer to create a layer from a shapefile or GDB feature class – Bjorn May 23 '17 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. – dexgecko May 23 '17 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 May 23 '17 at 21:40