This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from http://stackoverflow.com/questions/18141547/display-all-the-names-of-databases-containing-particular-table | |
# | |
# Reference: 1) http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/create-database-connection.htm | |
# 2) http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm | |
import arcpy | |
conn_path = # Output folder for database connection file | |
conn_name = # Output name of database connection file, including .sde extension |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# Reference: 1) https://pro.arcgis.com/en/pro-app/arcpy/data-access/walk.htm | |
# 2) https://pro.arcgis.com/en/pro-app/arcpy/functions/describe.htm | |
# 3) https://docs.python.org/3/library/os.path.html | |
import arcpy | |
import os | |
gdb = # Path to geodatabase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from http://gis.stackexchange.com/questions/66551/can-arcpy-10-1-be-used-to-generate-true-curve-elliptical-polygons-in-a-file-geod | |
# | |
# Reference: 1) http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/asshape.htm | |
# 2) http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geometry_Objects/02r3000000n1000000 | |
import arcpy | |
# Example 1: CIRCULARSTRING(1 5, 6 2, 7 3) | |
esri_json = { | |
"curvePaths": [[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: 1) https://docs.python.org/3/library/time.html | |
# 2) https://docs.python.org/3/library/os.path.html | |
from time import ctime | |
from os.path import getmtime, getctime, split | |
gdb = # Path to file geodatabase | |
# Example 1: Creation and Modficiation Dates | |
print "{}\t{}\t{}".format(split(gdb)[1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: 1) https://mkleehammer.github.io/pyodbc | |
# 2) https://docs.python.org/3/library/re.html#regular-expression-objects | |
import pyodbc | |
import re | |
driver_regexes = { | |
"mssql": ("ODBC Driver.*SQL Server", "SQL Server Native Client.*"), | |
"oracle": ("Oracle in.*") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# Reference: 1) https://pro.arcgis.com/en/pro-app/arcpy/functions/describe.htm | |
# 2) https://pro.arcgis.com/en/pro-app/tool-reference/data-management/add-field.htm | |
# 3) https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field.htm | |
import arcpy | |
# Example 1: Adding path attribute for tables and feature classes in workspace (ArcMap and Pro compatible) | |
workspace = # Workspace containing feature classes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# Reference: 1) https://www.opengeospatial.org/standards/sfa | |
geoms = { | |
'pt': 'POINT(10 10)', | |
'ept': 'POINT EMPTY', | |
'mpt': 'MULTIPOINT((15 15), (25 15))', | |
'empt': 'MULTIPOINT EMPTY', | |
'ln': 'LINESTRING(20 20, 30 30)', | |
'eln': 'LINESTRING EMPTY', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# Reference: 1) https://pro.arcgis.com/en/pro-app/arcpy/classes/spatialreference.htm | |
# 2) https://pro.arcgis.com/en/pro-app/arcpy/classes/array.htm | |
# 3) https://pro.arcgis.com/en/pro-app/arcpy/classes/point.htm | |
# 4) https://pro.arcgis.com/en/pro-app/arcpy/classes/polyline.htm | |
import arcpy | |
SR = arcpy.SpatialReference(4326) | |
interval = 5 # Interval of latitude and longitude lines, multiple of 1 degree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python2 | |
# Example 1a adapted from https://www.reddit.com/r/gis/comments/4rhvhh/map_automation_arcpymapping_make_lyr/ | |
# | |
# Reference: 1) http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/layer-class.htm | |
# 2) https://docs.python.org/2/library/json.html | |
import arcpy | |
import json | |
lyr = # Layer object, typically from arcpy.mapping.ListLayers (arcpy._mapping.Layer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# Reference: 1) https://pro.arcgis.com/en/pro-app/arcpy/classes/spatialreference.htm | |
# 2) https://pro.arcgis.com/en/pro-app/arcpy/classes/array.htm | |
# 3) https://pro.arcgis.com/en/pro-app/arcpy/classes/polygon.htm | |
# 4) https://pro.arcgis.com/en/pro-app/arcpy/data-access/updatecursor-class.htm | |
# 5) https://docs.python.org/3/library/itertools.html | |
import arcpy | |
from itertools import takewhile |
OlderNewer