Created
January 19, 2016 18:24
-
-
Save maphew/e7ed7b8a462c48892c7b to your computer and use it in GitHub Desktop.
A refinement of @FelixIP's solution to http://gis.stackexchange.com/questions/177044/calculate-z-median-from-3d-line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sources