1

I am looking for a way to copy attribute values from one attribute table to another. I am mainly looking to do this using python, so would prefer a way to do this with a tool or a a stand-alone python script.

A little background about my problem. I have a collection of polylines situated within a collection of polygons (a watercourse network). The crux of what I want to do is identify, spatially, which polygons hold which polylines and record this in the relevant field. The script below shows how far I have got. I have used python to select the relevant polygon and highlight the polylines that are situated inside it (selected features). However, I have so far been unable to copy these selected features into a particular field of another feature class. I have tried using both the Append (got 'warning' 000597) and Join tools but neither have worked.

import arcpy

reachesBoundaries = "C:\Users\maureen\Documents\ArcGIS\EDRN\Catchments\MainRiversCatchmentsPolygonMarch2013.shp"
edrnLink = "C:\Users\maureen\Documents\ArcGIS\EDRN\EDRN_LINK.shp"
reachField = "CATCHNAME"
reachName = "Aire - Lady Beck Catchment"

arcpy.MakeFeatureLayer_management(edrnLink, "edrnLayers9")
arcpy.MakeFeatureLayer_management(reachesBoundaries, "boundaryLayer8", '"' + str(reachField) + '" =' + "'" + str(reachName) + "'")

arcpy.SelectLayerByLocation_management("edrnLayer9", "WITHIN", "boundaryLayers8")

The script works up the point mentioned above, if anyone has any ideas on how to progress it, please let me know.

2 Answers 2

3

This is typically something that you can do with a spatial join. However, you should be aware that you cannot have several lines copied in a single feature : one feature can only store one line. With the spatial join, you can use "one-to-many" in order to duplicate your records when there are several relationships.

2

Do the lines break where they cross polygon boundaries? Or if not, is it ok to break them? If so, the identity tool will do what you want. Lines will be broken so each one lies within only one polygon, and each line will acquire the attributes of the polygon that encloses it. Or if you don't have an ArcInfo license, you can use intersect, but make sure your polygons cover the full extent of your lines or you will lose lines. Just add a dummy polygon if you need to.

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.