Skip to content

Instantly share code, notes, and snippets.

@cindygis
cindygis / createAssetFolderStructure.py
Created July 13, 2015 16:45
Creates the folder structure for asset management GIS data. Must still be optimised
import os
folder_assetarea = r"C:\Assets\AreaA" # The main folder for Area A
year = "2015" # The year to create the structure for
folder_year = os.path.join(fld_mun, year)
folder_list = [["conversion", ["cad_gis", "ftr_shp", "kml_gdb",
"pdf_jpg", "shp_gdb", "tbl_xls",
"xls_tbl",] "jpg_gis", "gps_gis",
@cindygis
cindygis / createRandomPointsAsJSON.py
Created July 9, 2015 07:55
Creates a point feature class in memory containing random points within a predefined extent, and posts the points as ESRI JSON to a REST endpoint.
#
# @date 13/05/2015
# @author Cindy Williams
#
# Creates a point feature class in memory containing
# random points within a predefined extent, and posts
# the points as ESRI JSON to a REST endpoint.
#
# For use as a standalone script
#
@cindygis
cindygis / genAttachmentMatchTable.py
Created July 1, 2015 09:32
Generates a file gdb table containing the paths of photos to be attached to matching points as feature attachments..
#
# @date 01/07/2015
# @author Cindy Williams
#
# Generates a file gdb table containing the paths
# of photos to be attached to matching points as feature
# attachments.
#
# For use as a standalone script.
#
@cindygis
cindygis / linesToPolysToCentroids.py
Created June 26, 2015 19:42
Creates centroids from closed lines by creating temporary polygons.
#
# @date 26/06/2015
# @author Cindy Williams
#
# Creates centroids from closed lines by creating temporary
# polygons.
#
# For use as as a standalone script.
#
@cindygis
cindygis / createFCsfromDataFrame.py
Created June 24, 2015 13:34
Creates feature classes by looking up the name in a pandas data frame
#
# @date 24/06/2015
# @author Cindy Williams
#
# Creates feature classes by looking up the
# name in a pandas data frame
#
# For use as a standalone script
#
@cindygis
cindygis / getArcCatalogConnectionsFolder.py
Last active August 29, 2015 14:22
Gets the folder path where ArcCatalog connections are stored
import arcpy
import os
# Detailed description
os_appdata = os.environ['APPDATA'] # Current user's APPDATA folder
folder_esri = "ESRI" # ESRI folder name
arc_prod = arcpy.GetInstallInfo()['ProductName'] # Get the installed product's name e.g. Desktop
arc_ver = arcpy.GetInstallInfo()['Version'] # Get the installed product's version number
arc_cat = "ArcCatalog" # ArcCatalog folder name
@cindygis
cindygis / batchDefineProjection.py
Last active August 29, 2015 14:22
Defines the projection for a folder of shapefiles.
import arcpy
arcpy.env.workspace = r"C:\Some\Arb\Folder"
# Define spatial reference WGS 84
sr = arcpy.SpatialReference(4326)
for shp in arcpy.ListFeatureClasses():
arcpy.management.DefineProjection(shp, sr)
print("Defined " + shp)
@cindygis
cindygis / displayDuplicateValuesInField.py
Last active August 29, 2015 14:22
Displays the key values that are duplicates in a list of attribute field values.
#
# @date 29/05/2015
# @author Cindy Williams
#
# Checks an attribute field for duplicate values,
# and displays them along with the amount of duplicates.
#
# For use in the Python window in ArcMap.
#
@cindygis
cindygis / updateLayerNameWithGroupName.py
Created May 29, 2015 12:02
Updates a layer name with the name of the group layer it is in.
#
# @date 29/05/2015
# @author Cindy Williams
#
# Updates a layer name with the name of the group layer
# it is in, in an existing mxd.
#
# For use in the Python window in ArcMap.
#
@cindygis
cindygis / updateSymbologyBasedOnDomain.py
Last active August 29, 2015 14:21
Updates the values for a unique symbology renderer based on range domain values.
#
# @date 27/05/2015
# @author Cindy Williams
#
# Updates the values for a unique symbology renderer
# based on range domain values. The layer must have
# the unique symbols renderer enabled manually.
#
# For use in the Python window in ArcMap.
#