Converting points using FeatureClassToNumPyArray to interpolate cross-section with sc

المشرف العام

Administrator
طاقم الإدارة
Can someone please help! I'm trying to plot elevation cross section and extract elevations along a cross section using scipy's "interpolate" function. I'm converting a point feature class of profile elevation points to 2 numpy arrays representing "distance" and "elevation", respectively.

Here is my code:

import numpyimport arcpyfrom scipy import interpolateimport matplotlib.pyplot as pltarcpy.env.workspace = "D:\\NJBPN\\volume_calc_scripts\\test_njbpn.gdb"#interpolate profilex = arcpy.da.FeatureClassToNumPyArray("test_prof",["Distance"])y = arcpy.da.FeatureClassToNumPyArray("test_prof",["Z"])f = interpolate.interp1d(x,y,kind='linear')xnew = numpy.arange(numpy.amin(x, axis = 0),numpy.amax(y, axis = 1))ynew = f(xnew)interpolate.interp1d._call_(xnew)plt.plot(x,y,'o',xnew,f(xnew),'-')plt.legend(['data', 'linear'], loc='best')plt.show()It keeps giving the following error:

Runtime error Traceback (most recent call last): File "", line 12, in File "C:\Python27\ArcGIS10.2\lib\site-packages\numpy\core\fromnumeric.py", line 1987, in amin out=out, keepdims=keepdims) File "C:\Python27\ArcGIS10.2\lib\site-packages\numpy\core_methods.py", line 14, in _amin out=out, keepdims=keepdims)TypeError: cannot perform reduce with flexible type

Here is an updated code to extract the xnew value at ynew=0

xnew = numpy.arange(numpy.amin(x),numpy.amax(x)).astype(numpy.int)ynew = f(xnew).astype(numpy.float)shorelinedist = numpy.where(ynew==0.00,[xnew]plt.plot(x,y,'o',xnew,ynew,'-')plt.legend(['data', 'linear'], loc='best')plt.show()

أكثر...
 
أعلى