Skip to content

Instantly share code, notes, and snippets.

@maphew
Created January 19, 2016 18:24
Show Gist options
  • Save maphew/e7ed7b8a462c48892c7b to your computer and use it in GitHub Desktop.
Save maphew/e7ed7b8a462c48892c7b to your computer and use it in GitHub Desktop.
# In ArcGIS Field Calculator, pre-logic script code box:
import numpy
def getMedian(shp):
aList=[]
part=shp.getPart(0)
n=len(part)
for i in xrange(n):
p=part.getObject(i)
z=p.Z
aList.append(z)
#aList.sort()
#return aList[n/2]
return numpy.median(numpy.array(aList))
# Call with:
#
# getMedian(!Shape!)
@maphew
Copy link
Author

maphew commented Jan 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment