I have layers of points and lines that have to be updated regularly.

It needs to have the intersecting attributes from another layer stored in its fields/attribute table. IE. towns, school districts etc, and roadnames etc.

so for a layer of points, what town, school district and street name each point is in/on. it was so easy with ArcGIS 9 using VBA, but need a little help getting started using ArcGIS 10.1 and Python.

  • 1
    Welcome to GIS SE! As a new user be sure to take the Tour. Would you be able to edit your question to provide more detail about what you have tried so far? For example, I would just use a point-in-polygon overlay to transfer polygon attributes to points I.e. no need for Python code.
    – PolyGeo
    Jul 6, 2015 at 12:39
  • 1
    GIS SE is more about helping you finish scripts than start them. If you don't demonstrate some effort on your own behalf it's unlikely that anyone else will either. Please edit this question to contain your first draft toward solving the problem, with details about how it varies from expectations.
    – Vince
    Jul 6, 2015 at 12:39

3 Answers 3


There's actually no need for Python for this. Look into a Spatial Join. Add your point and line feature classes to ArcMap, right-click on your points, Joins and Relates, Join..., Join data from another layer based on the spatial location. If you do wish to automate the process, arcpy has the Spatial Join tool.


You should look into Attribute Assistant, which can be downloaded as part of one of the templates from the Local Government Information Model like the Address Data Management template. The Dynamic Values Table lets you configure many automated behaviors during editing. To get data from a layer touched by a point you would use the Intersecting Features method in response to feature creation or changes in the point's geometry. After that just add the table to your map, enable the Attribute Assistant button on the Attribute Assistant toolbar and edit normally.


I answered a question here that is probably similar to what you want (the second part of the answer, which also links to this answer regarding Bakeries and States...). Using Spatial Join works also, but it creates another layer which might not be desirable.

Your code might look something like this...

import arcpy

# Set overwrite option
arcpy.env.overwriteOutput = True

# Create FeatureLayers
arcpy.MakeFeatureLayer_management("C:/YourFolder/YourPointsLayer.shp", "lyr_PointsLayer")
arcpy.MakeFeatureLayer_management("C:/YourFolder/SchoolDistricts.shp", "lyr_SchoolDistricts")

# Create a search cursor for the school districts
rows = arcpy.SearchCursor("lyr_SchoolDistricts")
for row in rows:
    # What you'll do is select each school district one at a time, and then select all the points in that school district and calculate the SCHOOLDIST field
    # NOTE: If you are using not using shapefiles, then you'll have to change the FID in the line below to OBJECTID (or similar)
    arcpy.SelectLayerByAttribute_management("lyr_SchoolDistricts", "NEW_SELECTION", "\"FID\" = " + str(row.getValue("FID")))
    arcpy.SelectLayerByLocation_management("lyr_PointsLayer", "INTERSECT", "lyr_SchoolDistricts", "", "NEW_SELECTION")
    arcpy.CalculateField_management("lyr_PointsLayer", "SCHOOLDIST", "'{0}'".format(str(row.getValue("DISTRICT"))), "PYTHON_9.3", "")
    print "Finished processing " + str(row.getValue("DISTRICT"))

In the code above, the "DISTRICT" field is the name of the field in the School Districts layer, and the "SCHOOLDIST" field is the field that's in the Points layer...

  • HI Jason, sorry this took so long. This example worked great. I finally used it and was able to get the results I needed. But I did come across another situation, where the bakeries and states problem took too long. it involves points and lines now. So I need to return the street name for every point. The streets shape has several thousand records and may be too much using above example. so how would I go about saving into each point attribute table, the underlying street name? Thanks so much for your help.
    – mwoody
    Oct 8, 2015 at 17:48

Your Answer

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

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