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
| """---------------------------------------------------------------------------- | |
| Name: $[ActiveDoc-Name] | |
| Description: | |
| Requirements: ArcGIS Desktop Standard (10.2) | |
| Python Version: 2.7 | |
| Inputs: | |
| Outputs: |
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
| def hasSelection(lyr): | |
| ''' Check whether specified layer has a selection. ''' | |
| import arcpy | |
| desc = arcpy.Describe(lyr) | |
| if len(desc.FIDSet) == 0: | |
| # Layer has no selection | |
| return False | |
| else: | |
| # Layer has a selection | |
| return True |
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
| def setNAN(): | |
| minx = float('nan') | |
| def checkNAN(): | |
| import math | |
| if math.isnan(minx): | |
| return 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
| def RotateXY(x,y,xc=0,yc=0,angle=0,units='DEGREES'): | |
| """Rotate an xy cooordinate about a specified origin | |
| returning a new xy cooordinate | |
| x,y xy coordinates | |
| xc,yc center of rotation | |
| angle angle | |
| units "DEGREES" (default) or "RADIANS" | |
| """ | |
| import math |
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
| def OpenLink([Hyperlink_Log], [Hyperlink_Log2], [Hyperlink_Photo], [Hyperlink_LabTest], [Hyperlink_Televiewer], [Hyperlink_Geonor], [Hyperlink_Instrumentation] ): | |
| """Open multiple hyperlinks fields via python""" | |
| import webbrowser | |
| import os | |
| mxd = arcpy.mapping.MapDocument("CURRENT") | |
| basePath = mxd.hyperlinkBase | |
| paths = [Hyperlink_Log], [Hyperlink_Log2], [Hyperlink_LabTest], [Hyperlink_Photo], [Hyperlink_LabTest], [Hyperlink_Televiewer], [Hyperlink_Geonor], [Hyperlink_Instrumentation] | |
| for path in paths: |
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
| def isCADLayer(layer): | |
| ''' Returns True if a layer is a CAD layer. | |
| ''' | |
| desc = arcpy.Describe(layer) | |
| if hasattr(desc, "dataType") and (desc.dataType == "FeatureLayer"): | |
| describeTable = arcpy.Describe(desc.catalogPath) | |
| if describeTable.dataElementType == "DEFeatureClass": | |
| describePath = arcpy.Describe(describeTable.path) | |
| if hasattr(describePath, "dataType") | |
| and (describePath.dataType == "CadDrawingDataset"): |
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
| Expression = "'{0}'".format(arcpy.GetParameterAsText(3)) # single quoted string literal |
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
| def getUniqueFieldValuesFromTable(in_table, in_field_name): | |
| ''' | |
| Use SearchCursor to return a list of unique values in the specified field | |
| in_table: The feature class, layer, table, or table view <string> | |
| in_field_name: Single field name <string> | |
| returns: pythonList | |
| ''' | |
| pySet = set() | |
| with arcpy.da.SearchCursor(in_table, in_field_name) as cursor: |
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
| import os | |
| def get_workspace(in_feature_class): | |
| ''' Get the workspace for a feature class''' | |
| workspace = os.path.dirname(in_feature_class) | |
| if [any(ext) for ext in ('.sde', '.gdb', '.mdb') if ext in os.path.splitext(workspace)]: | |
| return workspace | |
| else: | |
| return os.path.dirname(workspace) |
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
| import os | |
| import arcpy | |
| def create_output_gdb(parent_folder, gdb_name): | |
| """Creates a new gdb in the folder | |
| """ | |
| arcpy.AddMessage("Checking output workspace...") | |
| gdb_path = os.path.join(parent_folder, gdb_name + ".gdb") | |
| # Generate a unique name if the gdb already exists | |
| if arcpy.Exists(gdb_path): |
OlderNewer