Skip to content

Instantly share code, notes, and snippets.

View M-Bryant's full-sized avatar

Mark Bryant M-Bryant

  • AECOM
  • Auckland, New Zealand
  • 00:03 (UTC +13:00)
View GitHub Profile
@M-Bryant
M-Bryant / isCADLayer.py
Last active August 29, 2015 14:08
arcpy: checks if ArcMap layer is a CAD layer
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"):
@M-Bryant
M-Bryant / ArcMap multiple hyperlink via script
Created August 22, 2014 06:14
Open multiple relative hyperlinks in ArcGIS for Desktop (python)
@M-Bryant
M-Bryant / rotate point.py
Last active August 29, 2015 13:56
Rotate an xy cooordinate about a specified origin
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
@M-Bryant
M-Bryant / dummyNAN.py
Created November 24, 2013 20:47
arcpy: Set/Check Not a number (NAN)
def setNAN():
minx = float('nan')
def checkNAN():
import math
if math.isnan(minx):
return 1
@M-Bryant
M-Bryant / hasSelection
Created November 7, 2013 03:26
arcpy: Check whether specified layer has a selection
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
@M-Bryant
M-Bryant / Template
Last active May 17, 2019 15:25
arcpy: Sample Template
"""----------------------------------------------------------------------------
Name: $[ActiveDoc-Name]
Description:
Requirements: ArcGIS Desktop Standard (10.2)
Python Version: 2.7
Inputs:
Outputs: