Last active
July 21, 2018 09:53
-
-
Save cindygis/5ec6a0b9dae0c89fdd37f68567f51344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @author Cindy Jayakumar | |
# @date 21/07/2018 | |
# | |
# Extract domains from a field in one feature class, and apply | |
# it to matching fields in another feature class. | |
# | |
import arcpy | |
source_fc = r'C:\Some\Arb\Folder\test.gdb\source' | |
target_fc = r'C:\Some\Arb\Folder\test.gdb\target' | |
# Get field names and domains if applicable | |
source_fields = {field.name : field.domain for field in arcpy.ListFields(source_fc) if field.domain} | |
for field in arcpy.ListFields(target_fc): | |
if field.name in source_fields and field.domain is None: | |
arcpy.management.AssignDomainToField(target_fc, field.name, source_fields[field.name]) | |
print("Assigned {0} to {1}".format(source_fields[field.name], field.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment