有一个代码:为什么需要浮标?
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
print "Creating and defining X and Y coordinates:" #set env properties
env.workspace = r"C:\Users\Desktop\data\new"
env.overwriteOutput = 1
theme = '/watersheds_3D.shp' #polygons in vector format
demName = '/demlab4' # raster of DEM
rasObject = Raster(demName)
my_extent = rasObject.extent #find a grid cell size:
my_cellsize = (rasObject.meanCellHeight + rasObject.meanCellWidth)/2
print my_cellsize
slope_deg = Slope(demName)
slope_deg.save('/demlab4_slope')
for row in arcpy.da.SearchCursor(theme, ["FID","[email protected]"]): # inside shp file -
print ("Polygon # {}: ".format(row[0]))
for part in row[1]: # Inside the polygon
xCoords = []
yCoords = []
zCoords = []
for pnt in part:
print (" {}, {}, {} ".format(pnt.X, pnt.Y, pnt.Z))
xCoords.append(pnt.X)
yCoords.append(pnt.Y)
zCoords.append(pnt.Z)
area3D = lab4_arcpy_module.define3Darea(my_cellsize, slope_deg)
和函数来计算的:
def define3Darea(my_cellsize, slope_deg):
a = my_cellsize
slope_rad = math.pi * slope_deg/180 # return in radiant
c = math.sqrt(a**2 + (math.tan(slope_rad)*a)**2)
area3D = a*c
print "Total 3D Area is: ", area3D, "m^2"
return area3D
它给出:类型错误:需要的浮子。 什么是问题?
还需要计算每个多边形(4)内部的3D区域。怎么做?
您确实需要提供完整的错误消息,以便我们可以看到发生错误的位置。上下文就是一切! –