if the point is inside the polygon get data from a particular field while selected.

Discussion created by hchapa89 on Dec 10, 2013
Latest reply on Jan 22, 2014 by hua17
I found a snippet of code that returns if the point is inside the polygon. I like the idea but I want the code to do a little more than just that. For example, let's say I use my tool the selected features I select the points and the polygons that is touching that points. I want to get the data from the particular field to the point when only does that is selected. I think the code below will help on doing this ambitious task. Maybe someone else has already the answer I just need someone to lead me either to the answer to the question or lead me to the tools will need to write the script. I am thinking that the bottom script will help in such of way if not then correct me.

import arcpy
def point_in_poly(poly, x, y):
    """Returns if the point is inside the polygon.
        poly: arcpy.Polygon() geometry
        x:    x coordinate (float)
        y:    y coordinate (float)
    pg = arcpy.PointGeometry(arcpy.Point(x, y), poly.spatialReference)
    return poly.contains(pg)