Skip to content

Instantly share code, notes, and snippets.

View mfunk's full-sized avatar

Matt Funk mfunk

View GitHub Profile
@mfunk
mfunk / selectUTMZone.py
Created August 1, 2018 18:35
Returns ArcPy spatial reference for input lat/long location.
def selectUTMZone(self, longitude, latitude):
'''
return UTM/UPS Zone spatial reference based on longitude and latitude
* Datum is GCS_WGS_1984
Based on gis.stackexchange.com referenced on 1/24/2017:
http://gis.stackexchange.com/questions/13291/computing-utm-zone-from-lat-long-point
Inputs:
longitude: latitude (assume GCS WGS 1984) of UTM zone
@mfunk
mfunk / ArcGIS_gp_exception_block_python.py
Created April 13, 2016 16:25
Small exception block for ArcGIS geoprocessing tools
import sys
import traceback
except arcpy.ExecuteError:
# Get the tool error messages
msgs = arcpy.GetMessages()
arcpy.AddError(msgs)
print(msgs)
except:
@mfunk
mfunk / GeoprocessingScriptToolTemplate.py
Last active December 4, 2020 23:18
ArcGIS Geoprocessing Script template
# coding: utf-8
'''
------------------------------------------------------------------------------
Copyright 2016 Esri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@mfunk
mfunk / PythonToolboxTemplate.pyt
Last active December 4, 2020 23:18
Python Toolbox (PYT) Template for ArcGIS
# coding: utf-8
'''
------------------------------------------------------------------------------
Copyright 2016 Esri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@mfunk
mfunk / GetApplication.py
Created October 16, 2015 17:20
GetApplication() checks for Pro or Desktop as a Python snippet
def GetApplication():
'''Return app environment as ARCMAP, ARCGIS_PRO, OTHER'''
try:
from arcpy import mp
return "ARCGIS_PRO"
except ImportError:
try:
from arcpy import mapping
mxd = arcpy.mapping.MapDocument("CURRENT")
return "ARCMAP"
@mfunk
mfunk / apache_license_header.py
Last active April 6, 2016 14:45
Apache v2.0 License Header for Python (2016)
# coding: utf-8
'''
------------------------------------------------------------------------------
Copyright 2016 Esri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0