Feature Layer Template/master

581
5
04-08-2019 05:17 AM
OisinSlevin
New Contributor III

Is there a way to create a feature layer Template / Master layer ?
Currently I have to create several Feature classes for different areas,

Each being identical just containing different data.

Is it possible to create a Template or Master feature layer such that if I updated the Template the column headers, properties would update on all feature layers associated ? 

0 Kudos
5 Replies
KoryKramer
Esri Community Moderator

Were you able to come up with anything to figure this out?

0 Kudos
OisinSlevin
New Contributor III

No Good Solution as of yet, working towards having all Feature classes with a naming convention, using python to find all layers that should follow a template, modifying based on a manual input (ex : "change all columns called "XXX" to "YYY" or Add a Layer called "ZZZ" to every feature collection)  - very messy, every solution I can come up with is very user input heavy. 

I'm constantly having to create a new set of feature classes for new areas (working with large amounts of data in small locations using one large feature class is too cumbersome for arcgis pro) - I have no ability to find folders in python when looking for feature classes makes grouping layers that are related difficult (some feature classes I need to have a read only and others as write only) 

Any suggestions would be great also I'm using Arcgis in python scripts only, I rarely use ArcGis pro as most of the work I'm doing has to be run based on a trigger or schedule. 



0 Kudos
ThomasColson
MVP Frequent Contributor

What is the storage format of your data? In principal, no, there is no way to propogate attribute column changes globally. Python is the closest approximation to accomplish this, either to modify an existing field or add new, to very many feature classes at once. 

0 Kudos
KoryKramer
Esri Community Moderator

Python, or Batch geoprocessing with Add Field Batch geoprocessing—ArcGIS Pro | ArcGIS Desktop 

If you're modifying fields, it looks like the Alter Field tool doesn't support Batch, so you'd be back to Python.

0 Kudos
ThomasColson
MVP Frequent Contributor

I use something like this, that will check if a required domain exits, if the domain exists, check for required values, check if a field exists, and assign the domain to the field. It will also add things if they don't exist at all. Can be easily modified to meet your requirement..

try:
# 2 Create COUNTY field and TLU_COUNTY domain if user checked box
in_Field = "COUNTY"
if str(isCOUNTYchecked) == 'true':
TLU_COUNTYDict = {"Swain":"Swain", "Blount": "Blount", "Sevier": "Sevier", "Cocke": "Cocke", "Haywood": "Haywood", "Graham": "Graham", "Monroe": "Monroe"}
domains = arcpy.da.ListDomains(gdb_name)
domain_names = [domain.name for domain in domains]
if 'TLU_COUNTY' in domain_names :
arcpy.AddWarning("TLU_COUNTY already exists")
for domain in domains:
if domain.name == 'TLU_COUNTY':
values = [cv for cv in domain.codedValues]
if not set(set(["Swain", "Blount", "Sevier", "Cocke", "Haywood", "Graham", "Monroe"])).issubset(values):
arcpy.AddWarning("TLU_COUNTY is missing a coded value pair.")
for code in TLU_COUNTYDict:
arcpy.AddCodedValueToDomain_management(gdb_name, "TLU_COUNTY", code, TLU_COUNTYDict

)
 arcpy.AddWarning("But Sasquatch took care of it.")
 else:
 arcpy.SetParameterAsText(10, gdb_name)
 arcpy.CreateDomain_management(gdb_name, "TLU_COUNTY", "County feature occurs in", "TEXT", "CODED")
 arcpy.AddMessage ("Sasquatch created the TLU_COUNTY domain")
 for code in TLU_COUNTYDict: 
 arcpy.AddCodedValueToDomain_management(gdb_name, "TLU_COUNTY", code, TLU_COUNTYDict
)
 arcpy.AddMessage ("Sasquatch added coded domain values to the TLU_COUNTY domain")
 
 
 if len(arcpy.ListFields(fc_name,in_Field))>0:
 arcpy.AddWarning (in_Field+" exits already")
 else:
 arcpy.AddField_management(fc_name, in_Field, "TEXT", "", "", 30, in_Field, "NULLABLE", "NON_REQUIRED", "TLU_COUNTY")
 arcpy.AddMessage ("Sasquatch created the "+in_Field+" field and the attribute domain is TLU_COUNTY")
 arcpy.AssignDefaultToField_management(fc_name, in_Field)
 else:
 arcpy.AddWarning(in_Field+" field will not be created")