Skip to content

Instantly share code, notes, and snippets.

View M-Bryant's full-sized avatar

Mark Bryant M-Bryant

  • AECOM
  • Auckland, New Zealand
  • 01:35 (UTC +13:00)
View GitHub Profile
@M-Bryant
M-Bryant / query_domain.py
Created April 19, 2016 01:58
arcpy: Query domains
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]))
@M-Bryant
M-Bryant / sortValues.py
Last active August 1, 2016 07:20
arcpy: Sort a separated value into an order
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)
@M-Bryant
M-Bryant / fieldExists.py
Last active April 4, 2022 07:48
arcpy: Check if field exists
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)]
@M-Bryant
M-Bryant / monotonic.py
Created December 14, 2016 00:53
Set of python functions for checking list of number increasing
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.
@M-Bryant
M-Bryant / list_join_tables.py
Last active February 17, 2017 04:58
arcpy: list joined tables
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]))

Commit Message Structure

<type>[optional scope]: <description>

Quick examples

  • feat: new feature
  • fix(scope): bug in scope
  • feat!: breaking change / feat(scope)!: rework API
  • chore(deps): update dependencies

Commit types