I have a table that has a field that matches a field in a feature class. the table has M records for 1 row in the feature class. I would like each row in the table to have the geometry of the feature class. This would result in stacked geometries with different attributes.
If this were a 1:1 relationship, I would join the table to the FC and then export for the result I want. if I join the FC to the table the attributes line up, but there is no geometry included in the table.
Any Ideas on a tool or workflow for this?
I am working with 10.3 standard.
Answer
- Transfer coordinates of polygon centroids into table.
- Create XY events from relevant columns
- Buffer points to get M wrong shape polygons:
Run this field calculator expression on field Shape:
mxd = arcpy.mapping.MapDocument("CURRENT")
LR=arcpy.mapping.ListLayers(mxd)[0]
def getShape(id):
with arcpy.da.SearchCursor (LR,["ID","Shape@"],'"ID" ='+str(id)) as cursor:
for i,shp in cursor: break
return shp
getShape( !ID! )
To import correct shapes:
In the picture above "table" polygons labelled by one of their attribute. NOTE: tested on shapefiles with common field ID of integer type. Query in search cursor will change if used on FGDB or different field type.
No comments:
Post a Comment