Skip to content

Instantly share code, notes, and snippets.

View danmaps's full-sized avatar
🏠
Working from home

Danny McVey danmaps

🏠
Working from home
  • SCE
  • Redlands, CA
View GitHub Profile
@danmaps
danmaps / orderby_issue.py
Last active November 5, 2015 20:02
This query only seems to fail under these very specific circumstances and when the last record has a null value in a search field.
import arcpy
import os
import shutil
import tempfile
GDB_NAME = 'test.gdb'
FEATURE_CLASS_NAME = 'Widget'
FEATURE_CLASS_TYPE = 'POINT'
FEATURE_CLASS_FIELDS = (
('StaticID', 'LONG', None),
@danmaps
danmaps / .block
Last active April 4, 2016 15:04
Iterate Date Field in Field Calculator
license: gpl-3.0
@danmaps
danmaps / .block
Last active April 4, 2016 14:46
Vector tiles - 4.0beta3
license: gpl-3.0
@danmaps
danmaps / .block
Last active April 4, 2016 14:47
Feature Table with hyperlinks
license: gpl-3.0
@danmaps
danmaps / .block
Last active April 4, 2016 14:46
Python temp
license: gpl-3.0
@danmaps
danmaps / .block
Last active April 5, 2016 16:49
Esri Leaflet
Copyright 2015 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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
def createScript():
import os
tbx_path = r"D:\sfe\MOTOROLA.tbx"
tbx_alias = "MOTOROLA"
modelname = "Model1-frequency"
outputLocation = r"D:\sfe\MOTOROLA\PYTHONS"
outScript = open(os.path.join(outputLocation, "outScript.py"), "w")
outScript.write("import arcpy\n")
mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd):
... if lyr.supports("DATASOURCE"):
... print "Count:" + str(arcpy.GetCount_management(lyr.dataSource))+"\tLayer: " + lyr.name
import os
from math import log
######################################
# http://stackoverflow.com/a/10171475
unit_list = zip(['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'], [0, 0, 1, 2, 2, 2])
def sizeof_fmt(num):
"""Human friendly file size"""
if num > 1:
exponent = min(int(log(num, 1024)), len(unit_list) - 1)
@danmaps
danmaps / curves.py
Last active March 14, 2017 16:41
python to identify curved segments
import arcpy, json
fc = "C:\Proj\Proj.gdb\curve"
fields=["SHAPE@", "OBJECTID"] # replace OBJECTID with any unique ID field
with arcpy.da.SearchCursor(in_table=fc,field_names=fields,where_clause="") as cur:
count = 0
for row in cur: