I’m working on modernizing our Planning and Zoning map. The way it is currently set up is that there are attribute fields set up for Rezones, Special Use Permits, and Variances. It has worked well enough, but the problem is that storing them via attribute has meant that we can only have the most recent record. A parcel can be rezoned many times and have multiple different conditional uses applied to it, so this is less than ideal because of that. I created a relationship class to a table that will hold those going forward. The challenge I am facing is migrating our old data to the new relationship class. I can’t seem to find a way to move that data that is currently in the zoning feature class into the related table. The only way I’ve seen so far would be to manually enter that data for all 2000+ records, which would be quite a time sink. Is there a more efficient way to do this?
Solved! Go to Solution.
I figured out how to do this. Here are the steps I followed:
1. make sure that your target table has Global IDs enabled.
2. Set up your related table to have all the fields that will hold the data you are looking to migrate from the old layer. You will also need a field using the "type" GUID.
3. Create the relationship class using the GlobalID from your main table and the GUID field from the related table as the primary key.
4. Either export the old table you want to migrate to an excel file or copy it to an excel file.
5. Rearrange the table in excel to where the format matches your new related table EXACTLY. You should have the same number of columns and all the data types should be the same. (Ensure text items are formated as "text" in excel instead of general.
6. When your excel table matches the format of your related feature class, you can copy the data from excel and paste it over a blank row of the attribute table. As long as your global IDs were enabled, pasting that data will create the relationship.
Just thinking off the top of my head here, but could you perhaps make a copy of your feature class to a table? Then you delete any field you don't need and are left with just your Rezone field and some unique ID you can use for the relationship. Then you delete the Rezone field from your main feature class and you're done.
parent_key = "GlobalID"
child_key = "ParentID"
parent_fields = [parent_key, "fields", "to", "copy"]
child_fields = [child_key, "into", "the", "child"]
# Start an edit session if needed
with arcpy.da.UpdateCursor("parent_table", parent_fields) as update, arcpy.da.InsertCursor("child_table", child_fields) as insert:
for row in update:
insert.insertRow(row)
update.updateRow([row[0]] + [None] * (len(row) - 1))
# Close the edit session if needed
Untested, but this should simultaneously create related records with the relevant fields while nulling out the old data to avoid confusion.
I figured out how to do this. Here are the steps I followed:
1. make sure that your target table has Global IDs enabled.
2. Set up your related table to have all the fields that will hold the data you are looking to migrate from the old layer. You will also need a field using the "type" GUID.
3. Create the relationship class using the GlobalID from your main table and the GUID field from the related table as the primary key.
4. Either export the old table you want to migrate to an excel file or copy it to an excel file.
5. Rearrange the table in excel to where the format matches your new related table EXACTLY. You should have the same number of columns and all the data types should be the same. (Ensure text items are formated as "text" in excel instead of general.
6. When your excel table matches the format of your related feature class, you can copy the data from excel and paste it over a blank row of the attribute table. As long as your global IDs were enabled, pasting that data will create the relationship.