Skip to content

Instantly share code, notes, and snippets.

@cindygis
cindygis / updateRowsWithNestedLoop.py
Created December 4, 2015 06:22
Updates a field using a nested loop in an arcpy update cursor
import arcpy
lyr = arcpy.mapping.Layer(r'C:\Some\Arb\Folder\work.gdb\ftr_test')
cursor = arcpy.da.UpdateCursor(lyr, 'Name')
for i in xrange(10):
for e in ['X', 'Y']:
upd.next() # Increment the cursor
upd.updateRow(['Zone ' + str(i) + e])
@cindygis
cindygis / addFieldWithExtendTable.py
Last active March 31, 2016 06:45
Adds a new field using a numpy array to layers in a map document.
'''
@date 12/10/2015
@author Cindy Williams
Adds a new field to layers in a map document, based
on a current field.
For use in the Python window in ArcMap.
'''
@cindygis
cindygis / splitLineAtInteractivePoint.py
Created October 6, 2015 13:39
Uses an arcpy FeatureSet to allow the user to interactively create points on a line which will be used to split that line into parts, while retaining all attributes.
'''
@date 06/10/2015
@author Cindy Williams
@version 1.0
Uses an arcpy FeatureSet to allow the user to interactively create
points on a line which will be used to split that line into parts,
while retaining all attributes.
Requirements:
@cindygis
cindygis / extractDOCtablesToXLS.py
Created September 29, 2015 08:53
Writes the contents of all rows from multiple tables in a Word document to a spreadsheet.
import docx
import xlwt
doc = r"C:\Some\Arb\Folder\input.docx"
xls = r"C:\Some\Arb\Folder\output.xls"
document = docx.Document(doc)
book = xlwt.Workbook()
cur_sheet = book.add_sheet("Tables")
row_num = 0
@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 / convertMultiPagePDFtoTIFF.py
Created August 18, 2015 07:47
Converts a range of pages from a pdf to separate tiff files using the PDF to TIFF tool added at ArcGIS 10.3.
#
# @date 18/08/2015
# @author Cindy Williams
#
# Converts a range of pages from a pdf to separate tiff
# files using the PDF to TIFF tool added at ArcGIS 10.3.
# For very basic conversion, with minimal error handling.
#
# 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.
#