1

I have a feature class that contains polygon features with a unique ID column. This shapefile is to be joined with a CSV table that I've exported to a file geodatabase table. The unique identifier in the table is the tuple (IDX, UID), there exists multiple columns with the same UID.

I would like to join the polygon feature and the table based on the relation ID=UID using ArcPy. That relation however is a one-to-one relation and I would like it to be a one-to-many relation so that one record in the polygon feature class table is joined with multiple records in the table.

Any ideas on how to do this using ArcPy?

1 Answer 1

0

So for each polygon, you will have to make a searchcursor that finds the matching csv rows. Next, add the first result to your existing polygon. For all the other results, copy the existing polygon and add it with the new metadata to the shapefile.

expression = arcpy.AddFieldDelimiters(csvFeatureClass,UIDfield) + " = " + UID
with arcpy.da.SearchCursor(scvFeatureClass,fields,where_clause=expression) as cursor:
 for row in cursor:
   metadata = row[fieldIDInFieldsVariable]
5
  • UID is a bad name, but yes, there are multiple rows with the same UID. The reason is that it is project data, and projects occur at different time intervals and I have thus split them into separate rows for each time interval.
    – Sebastian
    Commented Jul 31, 2014 at 14:09
  • What I want as result is a new feature class containing metadata from the table and shape data from the polygon feature class. Can Searchcursor be used to copy the actual polygons or only their metadata?
    – Sebastian
    Commented Jul 31, 2014 at 14:09
  • You have to be more specific: how do you want to save the data. Do you want copies of the same polygon for every row in your csv, or for each polygon multiple columns...
    – GeoSolve
    Commented Jul 31, 2014 at 14:12
  • I want copies of the same polygon for every row in my csv.
    – Sebastian
    Commented Jul 31, 2014 at 14:15
  • I updated my awnser with the cursor
    – GeoSolve
    Commented Jul 31, 2014 at 14:25

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