Skip to content

Instantly share code, notes, and snippets.

@cindygis
cindygis / convertXLStoGIS.py
Last active August 29, 2015 14:16
Takes a folder of spreadsheets and converts it to geodatabase tables using available arcpy tools.
#
# @author Cindy Williams
# @date 14/11/2014
#
# Takes a folder containing deeds data in spreadsheet
# format and converts it into a GIS table for further processing.
# It must adhere to a specific format.
#
# For use as a script tool in an ArcGIS Toolbox.
#
@cindygis
cindygis / exportMultiDDPasJPEG.py
Last active August 29, 2015 14:16
Exports data driven pages from a folder of map documents as JPEGs.
#
# @author Cindy Williams
# @date 23/08/2013
#
# Exports the data driven pages from a folder of
# map documents as JPEGs.
#
# For use as a script tool in an ArcGIS Toolbox.
#
@cindygis
cindygis / createCVDfromGen.py
Last active August 29, 2015 14:16
Creates a new coded value domain from values in a feature class using a generator expression.
#
# @date 25/02/2015
# @author Cindy Williams
#
# Extracts a list of values from a field in an attribute table
# to be used in a coded value domain.
#
# For use in the Python window in ArcCatalog.
#
@cindygis
cindygis / assignExistingDomainToField.py
Last active August 29, 2015 14:16
Adds a new field and assigns an existing domain to a feature class, or assigns the domain only if the field exists.
#
# @date 25/02/2015
# @author Cindy Williams
#
# Adds a new field to feature classes in a file GDB
# and assigns an existing domain to it. If the field
# exists, only the domain is assigned.
#
# For use in the Python window in ArcCatalog.
#
@cindygis
cindygis / getEsriWKT.py
Last active August 29, 2015 14:16
Returns the ESRI WKT for a given coordinate system from epsg.io
#
# @date 04/03/2015
# @author Cindy Williams
#
# Returns the ESRI WKT for a given EPSG from epsg.io
# Adapted from http://geospatialpython.com/2014/12/wkt-epsg-strings-made-easy.html
#
def getPRJwkt(epsg):
import urllib
@cindygis
cindygis / getPointDistanceAlongLine.py
Created March 6, 2015 13:07
Returns the distance a point is along a line.
#
# @date 06/03/2015
# @author Cindy Williams
#
# Returns the distance a point is along a line. Assumes that the
# existing point and line feature classes have the same spatial reference,
# and the points are snapped to the line.
#
# For use as a standalone script.
#
@cindygis
cindygis / toggleLabelsInMXD.py
Last active August 29, 2015 14:17
Set the label expression and switch on labels for all layers in an ArcMap document.
#
# @date 17/09/2014
# @author Cindy Williams
#
# Set the label field and switch labels on for
# all layers in a mxd.
#
# For use in the Python window in ArcMap.
#
@cindygis
cindygis / listSubtypesOfFC.py
Last active August 29, 2015 14:17
Prints out the key-values pairs of the dictionary of subtypes on a feature class.
import arcpy
ftr = r"C://Some//Arb//Folder//work.gdb//ftr"
subs = arcpy.da.ListSubtypes(ftr)
for k, v in subs.iteritems():
print k, v['Name']
@cindygis
cindygis / transferSTsAndCVDs.md
Last active August 29, 2015 14:17
Transfer descriptions of subtypes and coded value domains from feature class to shapefile

######Change this setting when exporting a feature class with subtypes and attribute domains to shapefile

####Transfer Field Domain Descriptions (Environment setting)

#####This geoprocessing environment controls whether output shapefiles and dBASE (.dbf) tables will have fields added containing domain and subtype descriptions, in addition to fields containing domain and subtype codes.

@cindygis
cindygis / listCodeValuesInCVD.py
Last active August 29, 2015 14:17
Prints out a list of code-value pairs for a given attribute domain in a workspace.
import arcpy
arcpy.env.workspace = "Database Connections\arb.sde"
cvd = "cvd_District"
for dom in arcpy.da.ListDomains():
if dom.name == cvd:
for i in dom.codedValues.iteritems():
print i
# One liner
cvd_pairs = [i for i in dom.codedValues.iteritems() for dom in arcpy.da.ListDomains() if dom.name == cvd]