<type>[optional scope]: <description>
feat: new featurefix(scope): bug in scopefeat!: breaking change/feat(scope)!: rework APIchore(deps): update dependencies
| import arcpy | |
| def list_join_tables(in_table): | |
| """Returns a list of tables currently joined to a table or feature class. | |
| List includes the in_table | |
| Returns empty list if no joins | |
| """ | |
| fields = [f.name for f in arcpy.Describe(in_table).fields] | |
| return = list(set([f.split(".")[0] for f in fields if "." in f])) |
| def strictly_increasing(L): | |
| """Returns TRUE if the values in the list are strictly increasing | |
| Always increasing; never remaining constant or decreasing or null. | |
| """ | |
| return all(x<y for x, y in zip(L, L[1:])) | |
| def strictly_decreasing(L): | |
| """Returns TRUE if the values in the list are strictly decreasing | |
| Always decreasing; never remaining constant or increasing or null. |
| import arcpy | |
| def fieldExists(dataset: str, field_name: str) -> bool: | |
| """Return boolean indicating if field exists in the specified dataset.""" | |
| return field_name in [field.name for field in arcpy.ListFields(dataset)] |
| def sortValues(the_value, delimiter=','): | |
| """Sort a separated value into an order | |
| Useful to run on ArcGIS processes where there is no control on returned values. | |
| For example SpatialJoin, JOIN_ONE_TO_ONE, with FieldMapping Merge Rule = Join | |
| """ | |
| if the_value == None: | |
| return the_value | |
| # Create a Python list by splitting the string on the delimeter | |
| the_list = the_value.split(delimiter) |
| domains = arcpy.da.ListDomains(r'C:\temp\test.gdb') | |
| for domain in domains: | |
| print(u'\nDomain name: {0}'.format(domain.name)) | |
| if domain.domainType == 'CodedValue': | |
| coded_values = domain.codedValues | |
| for val, desc in coded_values.iteritems(): | |
| print(u'\t{0} : {1}'.format(val, desc)) | |
| elif domain.domainType == 'Range': | |
| print(u'\tMin: {0}'.format(domain.range[0])) |
| import os | |
| import arcpy | |
| def create_output_gdb(parent_folder, gdb_name): | |
| """Creates a new gdb in the folder | |
| """ | |
| arcpy.AddMessage("Checking output workspace...") | |
| gdb_path = os.path.join(parent_folder, gdb_name + ".gdb") | |
| # Generate a unique name if the gdb already exists | |
| if arcpy.Exists(gdb_path): |
| import os | |
| def get_workspace(in_feature_class): | |
| ''' Get the workspace for a feature class''' | |
| workspace = os.path.dirname(in_feature_class) | |
| if [any(ext) for ext in ('.sde', '.gdb', '.mdb') if ext in os.path.splitext(workspace)]: | |
| return workspace | |
| else: | |
| return os.path.dirname(workspace) |
| def getUniqueFieldValuesFromTable(in_table, in_field_name): | |
| ''' | |
| Use SearchCursor to return a list of unique values in the specified field | |
| in_table: The feature class, layer, table, or table view <string> | |
| in_field_name: Single field name <string> | |
| returns: pythonList | |
| ''' | |
| pySet = set() | |
| with arcpy.da.SearchCursor(in_table, in_field_name) as cursor: |
| Expression = "'{0}'".format(arcpy.GetParameterAsText(3)) # single quoted string literal |