Problem with code in Python for viewshed?

المشرف العام

Administrator
طاقم الإدارة
I have the following code in which I import to a variable the number of points I want, that will produce the specific number of points and viewsheds, and compare each other to find the 3 with the biggest visible area. The problem I am facing is that I cannot run the entire code, but only if I run the second part (where the comment is) separately. The loop is wrong I am fixing it but is not my problem now.

import arcpyimport osfrom arcpy import envfrom arcpy.sa import *workspace = "C:/Calc_View/"values = 2num_pnts = int(values)MAXVIEW = ""MAXPNT = ""MIDDLEVIEW = ""MIDDLEPNT = ""SMALLVIEW = ""SMALLPNT = ""aa = 0bb = 0cc = 0n = 0for i in range(num_pnts): n += 1 # Spatially Balanced Points outPoints = "C:/Calc_View/point" + str(n) arcpy.CreateSpatiallyBalancedPoints_ga("rcls", 1, outPoints) inRaster = "rcls" inObserverFeatures = "point" + str(n) + ".shp" outViewshed = Viewshed(inRaster, inObserverFeatures) outViewshed.save("C:/Calc_View/view" + str(n))# It works only if I run it separately inpu = "view" + str(n) fields = ["VALUE", "COUNT"] C = arcpy.da.UpdateCursor(inpu, fields, """"VALUE" = 1""") for row in C: arithmos = row[1] if arithmos > aa: MAXVIEW = "view" + str(n) MAXPNT = inObserverFeatures elif arithmos > bb: MIDDLEVIEW = "view" + str(n) MIDDLEPNT = inObserverFeatures elif arithmos > cc: SMALLVIEW = "view" + str(n) SMALLPNT = inObserverFeatures else: arcpy.Delete_management(inObserverFeatures, "") arcpy.Delete_management("view" + str(n), "") print MAXVIEW, MAXPNT, MIDDLEVIEW, MIDDLEPNT, SMALLVIEW, SMALLPNT

أكثر...
 
أعلى