I have a polygon feature class and a point feature class. For each polygon, I would like to:
(1) Select the points contained in that polygon and
(2) Calculate the centroid of those selected points
Ideally, I would end up with a new point feature class called "centroids", for example, that would have a centroid for each polygon (they are named with "Name").
I'm a beginner in ArcPy, especially with search cursors. So far, I've tried writing something to iterate over each polygon (farm), select the points(turbines) within the farm, calculate the centroid of those points, and create a layer named "turbine_center"+the name of the farm. I'm running into an error in the SelectLayerByLocation tool:
turbines= working + "Turbines_eastern.shp"
farms_poly= working + "Farms_polygons.shp"
for farm in rows:
arcpy.SelectLayerByLocation_management("turbines_lyr", "intersect", farm)
Any help would be greatly appreciated!