Skip to content

Instantly share code, notes, and snippets.

View sofferm's full-sized avatar

Stefan Offermann sofferm

View GitHub Profile
@sofferm
sofferm / ArcMapExtent.px
Created March 8, 2017 08:29
Get Current Extent in ArcMap
arcpy.mapping.ListDataFrames(arcpy.mapping.MapDocument("CURRENT"))[0].extent.JSON
@sofferm
sofferm / gist:84b450f10e68d0638918
Created July 4, 2014 07:55
FME log function for Startup/Shutdown scripts
import time
def log(message):
print("%s | Python Shutdown | %s"%(time.asctime(),message))
with open(fme.logFileName,"a") as logfile:
logfile.write("%s | Python Shutdown | %s\n"%(time.asctime(),message))
@sofferm
sofferm / PublishServices.py
Created December 13, 2013 10:35
Publishes all mxd files in a folder to running arcgis services.
import arcpy
import os.path
# define local variables
wrkspc = r'C:\data\service_definitions'
arcpy.env.workspace = wrkspc
con = 'GIS Servers/arcgis on localhost_6080 (admin).ags'
for file in arcpy.ListFiles("*.mxd"):
file = os.path.join(wrkspc, file)
mapDoc = arcpy.mapping.MapDocument(file)
@sofferm
sofferm / Validate Cache Tool Patch
Created September 26, 2013 07:41
This patch fixes the problem of connection errors in the Esri ArcGIS "Validate Cache Tool" of Tom Brenneman. The original tool can be found here: http://resources.arcgis.com/gallery/file/enterprise-gis/details?entryID=632A4F2B-1422-2418-34C2-3BC3E9F063ED
try:
response = conn.getresponse() # line 244 in original findBadTiles.py
except:
# re-open connection
conn = httplib.HTTPConnection(parsedUrl.netloc)
conn.request("GET", partTileURL, headers=txtheaders)
response = conn.getresponse()
@sofferm
sofferm / makesig.py
Created September 9, 2011 21:53
Python Image Processing, writing text on image
import Image
import ImageDraw
import ImageFont
# string according to dokuwiki syntax for a table row
data = "| # | 19.11.2011 | DARK TRANQUILLITY, ELUVEITIE, VARG, MERCENARY, GURD, OMNIUM GATHERUM | FZW, Dortmund |"
# first band of the line up (to constrain text length)
subject = data.split("|")[3].split(',')[0].strip()
date = data.split("|")[2].strip()