Skip to content

Instantly share code, notes, and snippets.

View nickrsan's full-sized avatar

Nick Santos nickrsan

View GitHub Profile
"""
Allows you to pass in a list of environments to get the values of, then pass it back in to reset.
Usage:
original_envs = store_environments(["workspace","mask"]) # gives back a dict with current environment values for workspace and mask
arcpy.env.workspace = my_workspace
arcpy.env.mask = my_raster
# some more code here to do some work with those environments
@nickrsan
nickrsan / copy_field_attributes_to_new_field.py
Created May 3, 2016 17:35
Copies the attributes of a field (data type, precision, scale, length, isNullable, required, domain) to a new field on a new table. Correctly maps data types pulled from Describe tool to data types needed for field creation.
def copy_field_attributes_to_new_field(source_table, current_field, target_table, target_field):
"""
Copies the attributes of a field (data type, precision, scale, length, isNullable, required, domain) to a new field on a new table.
Correctly maps data types pulled from Describe tool to data types needed for field creation.
:param source_table: The table containing the existing field
:param current_field: The field to copy attributes from
:param target_table: The field to create the new field on
:param target_field: The name of the new field to create with the attributes from current_field
:return:
"""
@nickrsan
nickrsan / ArcGISPermanentOneToOneJoin.py
Last active May 11, 2016 20:53
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.
def permanent_join(target_table, target_attribute, source_table, source_attribute, attribute_to_attach, rename_attribute=None):
"""
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.
Or, in other words, 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
@nickrsan
nickrsan / Synchronize A495
Created September 9, 2012 02:17
Synchronizes two cameras without communication between them or a third party (remote). Designed for A495 and adapted from previous code - Works so long as the interval time is set to a number that divides evenly into 60 and that is longer than the time it
--[[
Author: Fraser McCrossan
Tested on G9, should work on most cameras.
Modified by Nick Santos for use in synchronizing two cameras.
Designed for A495 and adapted from previous code - Works so long as the interval time is set to a number that divides evenly into 60 and that is longer than the time it. Creative Commons Attribution licensed - please cite both authors above.
An accurate intervalometer script, with pre-focus and screen power off options.
Features: