Skip to content

Instantly share code, notes, and snippets.

@cindygis
cindygis / writeFieldsToDOC.py
Created September 21, 2015 09:07
Uses the python-docx package to write various properties of a feature class to docx format.
'''
@date 15/09/2015
@author Cindy Williams
Uses the python-docx package to write various
properties of a feature class to docx format.
'''
import arcpy
@cindygis
cindygis / convertSIDtoTiff.py
Last active September 18, 2015 10:37
Converts a folder of MRSID files to TIFF files.
'''
@date 2015/09/18
@author Cindy Williams
Converts a folder of MRSID files to TIFF files.
For use as a standalone script.
'''
import arcpy
@cindygis
cindygis / displayRasterProperties.py
Created September 3, 2015 12:40
Prints a comparison of the specified raster properties using arcpy and numpy.
#
# @date 25/08/2015
# @author Cindy Williams
#
# Prints a comparison of the specified raster
# properties using arcpy and numpy.
#
# For use as a standalone script.
#
@cindygis
cindygis / panZoomDataFramesToDDPDataFrame.py
Created September 1, 2015 09:57
Pans and zooms each data frame in an ArcMap document to the extent and scale of the data frame containing the data driven pages index layer before exporting.
#
# @date 25/08/2015
# @author Cindy Williams
#
# Pans and zooms each data frame in an ArcMap document
# to the extent and scale of the data frame containing
# the data driven pages index layer before exporting.
#
# For use as a standalone script.
#
@cindygis
cindygis / reformatAllLayerNames.py
Last active August 29, 2015 14:27
Quickly formats the names of all the layers in a map document.
#
# @date 14/08/2015
# @author Cindy Williams
#
# Quickly formats the names of all the layers in a map
# document. In this example, the part of the name before
# the first full stop is removed, underscores are replaced
# spaces, a regex is used to insert spaces before capitals
# and the string is converted to proper case.
#
@cindygis
cindygis / segmentLineByMeasures.py
Last active August 29, 2015 14:26
Creates segments along a selected line feature by splitting it according to a table of measures and saving it in a new feature class.
#
# @date 04/08/2015
# @author Cindy Williams
#
# Creates segments along a selected line feature
# by splitting it according to a table of measures
# and saving it in a new feature class.
#
# For use as a standalone script.
#
@cindygis
cindygis / convertSheetsAndDisplayXY.py
Created July 28, 2015 07:10
Converts all the sheets in a spreadsheet to file gdb tables and displays the XY coordinates in ArcMap.
#
# @date 28/07/2015
# @author Cindy Williams
#
# Converts all the sheets in a spreadsheet
# to file gdb tables and displays the XY
# coordinates in ArcMap.
#
# Assumes the spreadsheet has been formatted
# according to GIS standards.
@cindygis
cindygis / autoIncrementUniqueID.py
Created July 14, 2015 18:51
Populates the next highest numbers for a feature class based on the previous max
import arcpy
lyr = arcpy.management.MakeFeatureLayer(r"C:\Some\Arb\Folder\work.gdb\ftr_wrp_Pipe")
field = "GIS_ID"
def getWhereQry(exp):
return """ "{0}" IS {1} """.format(field, exp)
# Gets the previous highest GIS ID value. Set n = 0 for new feature class
n = max(int(row[0].split("-")[1]) for row in arcpy.da.SearchCursor(lyr, field, where_clause=getWhereQry("NOT NULL")))
@cindygis
cindygis / sortFeatureClassByExtent.py
Created July 14, 2015 18:28
Sorts a polygon feature class by descending X and ascending Y, to obtain the spatial order of the polys from left to right, top to bottom. Bypasses the Advanced licence needed to do this in the Sort tool.
#
# @date 13/07/2015
# @author Cindy Williams
#
# Sorts a polygon feature class by descending X and ascending Y,
# to obtain the spatial order of the polys from left to right,
# top to bottom. Bypasses the Advanced licence needed to
# do this in the Sort tool.
#
# For use in the Python window in ArcMap.
@cindygis
cindygis / selectVisibleFeaturesForDDPExport.py
Last active August 29, 2015 14:24
Intersects feature layers with the index layer for selected data driven export to a multi-page PDF with embedded layers.
#
# @date 13/07/2015
# @author Cindy Williams
#
# Intersects feature layers with the index layer
# for selected data driven export to a multi-page
# PDF with embedded layers.
#
# For use as a standalone script.
#