Skip to content

Instantly share code, notes, and snippets.

View alexfriant's full-sized avatar

Alex alexfriant

View GitHub Profile
@alexfriant
alexfriant / attribute_field_data_report.py
Last active September 24, 2019 16:54
Gives you a data report for the contents of an attribute table in arcgis shapefiles or geodatabase feature classes
#################################################################################
#
# Requirements: You'll need ArcGIS Desktop 10.1 or higher with Python 2.7+
#
# Give this script a shapefile or a feature class and it will give you a summary
# report for each field (column) in the attribute table. It helps you get a feel
# for how "complete" the attributes are populated during data assessment. It's
# useful if you need to compare two similar data sources too if you fiddle with
# the results in a spreadsheet program.
#
@alexfriant
alexfriant / set_global_layer_transparency.py
Created January 6, 2016 20:46
Change the transparency levels on all layers inside of your current ArcMap MXD document in one fell swoop!
##################################################################################################################
#
# Requirements: You'll need ArcGIS Desktop 10.1 or higher with Python 2.7+
#
# If you want to change Transparency for all the layers in your ArcMap MXD quickly, this will do the trick.
#
# 1. Copy / Paste the initial commands and function definitions below into an MXD's Python command shell, one-by-one
# 2. Use the command "setLayerTransparenciesTo(75)" to change every transparency to 75, or whatever you want
# (As a side note, notice that the Group Layers are set to 0 transparency. Play with this if you want!)
#
@alexfriant
alexfriant / gdb_feature_counts_report.py
Last active December 7, 2016 00:04
Give this script an entire Geodatabase and it reports the number of features in each feature class to a CSV file
###############################################################################
#
# Requirements: You'll need ArcGIS Desktop 10.1 or higher with Python 2.7+
# Use as a ArcToolbox Script Tool. Add the parameters as needed.
#
# Give this script an entire Geodatabase and it reports the number of
# attachments in attachment table and features in each feature class.
#
# The output is useful for comparing FC counts between multiple
# identical GDBs.
@alexfriant
alexfriant / change_image_sizes.py
Last active March 7, 2016 17:11
Modify image sizes for all images in a folder
from PIL import Image
import glob, os
size = 800, 600
for infile in glob.glob("c:/myphotos/*.jpg"):
file, ext = os.path.splitext(infile)
im = Image.open(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save(file + ".jpg", "JPEG")
@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
@alexfriant
alexfriant / extract_attachments.py
Created April 3, 2016 01:44
Extract attachments from ArcGIS file geodatabase
#############################################################################
# Requirements: ArcGIS 10.0 or higher, Python 2.7 or higher
#
# Description: Give this script an attachment table in a file geodatabase,
# and it will extract all the files and place them into the
# folder you designate.
#
# Note: Since attachments can have the same file name (i.e. Image00001.jpg)
# this script appends the attachment id to the file name so that every
# file is uniquely named in the folder you designate.
@alexfriant
alexfriant / gdb_get_editor_tracking_statuses.py
Last active August 4, 2017 23:03
Give this script an entire Geodatabase and it reports a list of it's feature classes and whether or not Editor Tracking is enabled.
###############################################################################
#
# Requirements: You'll need ArcGIS Desktop 10.1 or higher with Python 2.7+
# Use as a ArcToolbox Script Tool. Add the parameters as needed.
#
# Give this script an entire Geodatabase and it reports a list of its feature
# classes and whether or not Editor Tracking is enabled.
#
# The output is useful for managing Editor Tracking for a large number of
# feature classes.
@alexfriant
alexfriant / remove_gp_history_geodatabase.py
Last active August 30, 2017 22:53
Give this script a geodatabase (Personal, File, or SDE connection) and it will remove the "Geoprocssing History" contents from the Metadata in every Feature Class inside the geodatabase.
#################################################################################
#
# Requirements: You'll need ArcGIS Desktop 10.1 or higher with Python 2.7
#
# Give this script a geodatabase (Personal, File, or SDE connection) and it will
# remove the "Geoprocssing History" contents from the Metadata in every Feature
# Class inside the geodatabase.
#
# Before you attempt to use/run this script, make sure you have read the section
# near the top called "MODIFIABLE VARIABLES HERE".
@alexfriant
alexfriant / patternEyes.py
Last active August 31, 2022 21:21
This Python script will provide a summary of alphanumeric patterns which exist in a list of values
#####################################################################################
#
# Requirements: You'll need Python 3.5.1 or higher to run this
#
# This script will provide you a basic understanding of the alphanumeric patterns
# which exist in a list. You might get this list from a SQL query or something like
# that.
#
# INPUT: Give this script a file that has a single column of ID type strings.
# EXAMPLE (from command line):
@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))