I am trying to insert a value for different group of percentile eg (0- 10 percentitle) value = 1.
I saw an example over here and went to try it out How do I Calculate Grouped Percentiles or Batch percentiles in ArcMap?
However, i was thrown this error. I am using ArcGis 10.3.1 for desktop. and the file is Shapefile Feature Class.
Runtime error Traceback (most recent call last):File "", line 30, in File "", line 10, in CalcPercentileFile "C:\Python27\ArcGIS10.3\lib\site-packages\numpy\lib\function_base.py", line 3096, in percentilereturn _compute_qth_percentile(sorted, q, axis, out)File "C:\Python27\ArcGIS10.3\lib\site-packages\numpy\lib\function_base.py", line 3132, in _compute_qth_percentilereturn add.reduce(sorted[indexer]*weights, axis=axis, out=out)/sumvalTypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'numpy.ndarray'The source code is over here. (using python)
import arcpy import numpy as np import os #loop through all Shapefile in a folder and call the CalcPercentile method def CalcPercentile(inputFeatureClass): #to create 3 rank for example print inputFeatureClass; arr = arcpy.da.FeatureClassToNumPyArray(inputFeatureClass, 'NEAR_DIST_') p1 = np.percentile(arr, 33) # rank = 0 p2 = np.percentile(arr, 67) # rank = 1 p3 = np.percentile(arr, 100) # rank = 2 #use cursor to update the new rank field with arcpy.da.UpdateCursor(inputFeatureClass , ['NEAR_DIST_','PerRank1']) as cursor: for row in cursor: if row[0] < p1: row[1] = 0 #rank 0 elif p1
I saw an example over here and went to try it out How do I Calculate Grouped Percentiles or Batch percentiles in ArcMap?
However, i was thrown this error. I am using ArcGis 10.3.1 for desktop. and the file is Shapefile Feature Class.
Runtime error Traceback (most recent call last):File "", line 30, in File "", line 10, in CalcPercentileFile "C:\Python27\ArcGIS10.3\lib\site-packages\numpy\lib\function_base.py", line 3096, in percentilereturn _compute_qth_percentile(sorted, q, axis, out)File "C:\Python27\ArcGIS10.3\lib\site-packages\numpy\lib\function_base.py", line 3132, in _compute_qth_percentilereturn add.reduce(sorted[indexer]*weights, axis=axis, out=out)/sumvalTypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'numpy.ndarray'The source code is over here. (using python)
import arcpy import numpy as np import os #loop through all Shapefile in a folder and call the CalcPercentile method def CalcPercentile(inputFeatureClass): #to create 3 rank for example print inputFeatureClass; arr = arcpy.da.FeatureClassToNumPyArray(inputFeatureClass, 'NEAR_DIST_') p1 = np.percentile(arr, 33) # rank = 0 p2 = np.percentile(arr, 67) # rank = 1 p3 = np.percentile(arr, 100) # rank = 2 #use cursor to update the new rank field with arcpy.da.UpdateCursor(inputFeatureClass , ['NEAR_DIST_','PerRank1']) as cursor: for row in cursor: if row[0] < p1: row[1] = 0 #rank 0 elif p1