Skip to content

Instantly share code, notes, and snippets.

View alexfriant's full-sized avatar

Alex alexfriant

View GitHub Profile
@alexfriant
alexfriant / list_fields.py
Last active May 17, 2018 16:37 — forked from tyler-austin/arcpy_field_names.py
generate a list of field names for a feature class, with datatype and length
import arcpy, os
fc = os.path.join(r"path",r"to",r"your",r"featureclass")
field_list = [[field.name,field.type,str(field.length)] for field in arcpy.ListFields(fc)]
for field in field_list:
print(','.join(field))
@alexfriant
alexfriant / ArcGISPermanentOneToOneJoin.py
Last active November 16, 2022 17:43 — forked from nickrsan/ArcGISPermanentOneToOneJoin.py
Provides a way to permanently attach a field to another table, as in a one to one join, but without performing a join then exporting a new dataset. Operates in place by creating a new field on the existing dataset.
import arcpy
def permanent_join(target_table, target_attribute, source_table, source_attribute, attribute_to_attach, rename_attribute=None):
"""
Attaches a field to a dataset in place in ArcGIS - instead of the alternative of doing an actual join and then saving out a new dataset
Only works as a one to one join.
:param target_table: the table to attach the joined attribute to
:param target_attribute: the attribute in the table to base the join on
:param source_table: the table containing the attribute to join
:param source_attribute: the attribute in table2 to base the join on