本文整理汇总了Python中arcpy.SetProgressorPosition方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.SetProgressorPosition方法的具体用法?Python arcpy.SetProgressorPosition怎么用?Python arcpy.SetProgressorPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.SetProgressorPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_cls_boundary
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import SetProgressorPosition [as 别名]
def generate_cls_boundary(cls_input,cntr_id_field,boundary_output,cpu_core):
arcpy.env.parallelProcessingFactor=cpu_core
arcpy.SetProgressorLabel('Generating Delaunay Triangle...')
arrays=arcpy.da.FeatureClassToNumPyArray(cls_input,['SHAPE@XY',cntr_id_field])
cid_field_type=[f.type for f in arcpy.Describe(cls_input).fields if f.name==cntr_id_field][0]
delaunay=Delaunay(arrays['SHAPE@XY']).simplices.copy()
arcpy.CreateFeatureclass_management('in_memory','boundary_temp','POLYGON',spatial_reference=arcpy.Describe(cls_input).spatialReference)
fc=r'in_memory\boundary_temp'
arcpy.AddField_management(fc,cntr_id_field,cid_field_type)
cursor = arcpy.da.InsertCursor(fc, [cntr_id_field,"SHAPE@"])
arcpy.SetProgressor("step", "Copying Delaunay Triangle to Temp Layer...",0, delaunay.shape[0], 1)
for tri in delaunay:
arcpy.SetProgressorPosition()
cid=arrays[cntr_id_field][tri[0]]
if cid == arrays[cntr_id_field][tri[1]] and cid == arrays[cntr_id_field][tri[2]]:
cursor.insertRow([cid,arcpy.Polygon(arcpy.Array([arcpy.Point(*arrays['SHAPE@XY'][i]) for i in tri]))])
arcpy.SetProgressor('default','Merging Delaunay Triangle...')
if '64 bit' in sys.version:
arcpy.PairwiseDissolve_analysis(fc,boundary_output,cntr_id_field)
else:
arcpy.Dissolve_management(fc,boundary_output,cntr_id_field)
arcpy.Delete_management(fc)
return
示例2: clean
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import SetProgressorPosition [as 别名]
def clean(inputfield,targetfield):
fields = (inputfield, targetfield)
arcpy.SetProgressorLabel("Calculating field "+ inputfield)
# Create update cursor for feature class
#
with arcpy.da.UpdateCursor(map, fields) as cursor:
for row in cursor:
try:
row[0] = float(row[1])
except:
row[0] = -99.00000
# Update the cursor with the updated list
#
cursor.updateRow(row)
arcpy.SetProgressorPosition()
示例3: GetFieldInfo
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import SetProgressorPosition [as 别名]
def GetFieldInfo(gdb):
# Not being used any more.
#
# Assumption is that this is all dictated by the XML Workspace document so schema problems
# should not occur as long as the standard tools were used to create all databases.
#
# Create standard schema description for each geodatabase and use it in comparison
# to the rest of the tables
try:
env.workspace = gdb
tblList = arcpy.ListTables()
tblList.extend(arcpy.ListFeatureClasses())
tblList.extend(arcpy.ListRasters())
dSchema = dict()
arcpy.SetProgressorLabel("Reading geodatabase schema...")
arcpy.SetProgressor("step", "Reading geodatabase schema...", 0, len(tblList), 1)
for tbl in tblList:
tblName = tbl.encode('ascii').upper()
arcpy.SetProgressorLabel("Reading schema for " + os.path.basename(gdb) + ": " + tblName )
desc = arcpy.Describe(tblName)
fields = desc.fields
stdSchema = list()
for fld in fields:
stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper()))
#stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper(), fld.aliasName.encode('ascii').upper()))
dSchema[tblName] = stdSchema
arcpy.SetProgressorPosition()
arcpy.ResetProgressor()
return dSchema
except:
errorMsg()
return dict()
## ===================================================================================
示例4: calc_density_cpu
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import SetProgressorPosition [as 别名]
def calc_density_cpu(xs,ys,weights,kernel_type,cpu_core,cutoffd=0,sigma=0):
xs=xs-xs.min()
ys=ys-ys.min()
def calc_density_np(gidxys,result_q,xs,ys,weights,kernel_type,cutoffd=0,sigma=0):
while True:
try:
i=gidxys.get_nowait()
distpow2=(xs-xs[i])**2+(ys-ys[i])**2
if kernel_type=='GAUSS':
result_q.put( (i,((distpow2<((3*sigma)**2))*np.exp(-distpow2/(sigma**2))*weights).sum()))
else:
result_q.put( (i,((distpow2<(cutoffd**2))*weights).sum()))
except queue.Empty:
break;
n=xs.shape[0]
gidxys=queue.Queue()
result_q=queue.Queue()
for i in range(n):
gidxys.put(i)
arcpy.SetProgressor("step", "Calculate Densities on CPU...",0, n, 1)
ts=[]
for i in range(cpu_core):
t=Process(target=calc_density_np,args=(gidxys,result_q,xs,ys,weights,kernel_type,cutoffd,sigma))
t.start()
ts.append(t)
for t in ts:
while t.is_alive():
arcpy.SetProgressorPosition(n-gidxys.qsize())
time.sleep(0.05)
result_a=[]
while result_q.empty()==False:
result_a.append(result_q.get())
result_a.sort()
result_d=[]
for v in result_a:
result_d.append(v[1])
return np.array(result_d)
示例5: calc_nrst_dist_cpu
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import SetProgressorPosition [as 别名]
def calc_nrst_dist_cpu(gids,xs,ys,densities,cpu_core):
n=xs.shape[0]
def calc_nrst_dist_np(gidxys,result_q,gids,xs,ys,densities):
while True:
try:
i=gidxys.get_nowait()
distpow2=(xs-xs[i])**2+(ys-ys[i])**2
distpow2[densities<=densities[i]]=1e100
pg=distpow2.argsort()[0]
if distpow2[pg]>1e99:
result_q.put((i,1e10,-1))
else:
result_q.put((i,math.sqrt(distpow2[pg]),gids[pg]))
except queue.Empty:
break;
n=xs.shape[0]
gidxys=queue.Queue()
result_q=queue.Queue()
for i in range(n):
gidxys.put(i)
arcpy.SetProgressor("step", "Find Point with Higher Density on CPU...",0, n, 1)
ts=[]
for i in range(cpu_core):
t=Process(target=calc_nrst_dist_np,args=(gidxys,result_q,gids,xs,ys,densities))
t.start()
ts.append(t)
for t in ts:
while t.is_alive():
arcpy.SetProgressorPosition(n-gidxys.qsize())
time.sleep(0.05)
result_a=[]
while result_q.empty()==False:
result_a.append(result_q.get())
result_a.sort()
result_nd=[]
result_pg=[]
for v in result_a:
result_nd.append(v[1])
result_pg.append(v[2])
return (np.array(result_nd),np.array(result_pg))
示例6: GetGDBCount
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import SetProgressorPosition [as 别名]
def GetGDBCount(theInputDB, dSDMCounts, areaSym):
# Get record count from gSSURGO database
# Only those soil attributes present in the SDM database will be checked
# Some metadata and sdv tables are not found in SDM
try:
dGDBCounts = dict()
env.workspace = theInputDB
badCount = list()
PrintMsg(" \n\t\tGetting record count from gSSURGO tables", 0)
arcpy.SetProgressor("step", "Getting table record count from " + os.path.basename(theInputDB), 1, len(dSDMCounts), 1)
tblList = sorted(dSDMCounts)
for tbl in tblList:
arcpy.SetProgressorLabel(tbl)
sdmCnt = dSDMCounts[tbl]
if arcpy.Exists(tbl):
gdbCnt = int(arcpy.GetCount_management(os.path.join(theInputDB, tbl)).getOutput(0))
else:
raise MyError, "Missing table (" + tbl+ ") in " + os.path.basename(theInputDB)
badCount.append((os.path.join(theInputDB, tbl), 0, sdmCnt))
dGDBCounts[tbl] = gdbCnt
arcpy.SetProgressorPosition()
if sdmCnt != gdbCnt:
if sdmCnt == -1:
# SDA query failed to get count for this table
badCount.append((tbl, 0, gdbCnt, gdbCnt))
else:
# Record counts do not agree
badCount.append(( tbl, sdmCnt, gdbCnt, (sdmCnt - gdbCnt) ))
if len(badCount) > 0:
PrintMsg("\t\tDiscrepancy found in table counts:", 2)
PrintMsg(" \nTABLE, SDM, GDB, DIFF", 0)
for tbl in badCount:
PrintMsg(tbl[0] + ", " + str(tbl[1]) + ", " + str(tbl[2]) + ", " + str(tbl[3]), 0)
arcpy.SetProgressorLabel("")
arcpy.ResetProgressor()
if len(badCount) > 0:
return False
else:
return True
except MyError, e:
# Example: raise MyError, "This is an error message"
PrintMsg(str(e), 2)
return False
示例7: GetGDBCount
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import SetProgressorPosition [as 别名]
def GetGDBCount(theInputDB, dSDMCounts):
# Get record count from gSSURGO database
# Only those soil attributes present in the SDM database will be checked
# Some metadata and sdv tables are not found in SDM
try:
dGDBCounts = dict()
env.workspace = theInputDB
badCount = list()
PrintMsg(" \n\t\tGetting record count from gSSURGO tables", 0)
arcpy.SetProgressor("step", "Getting table record count from " + os.path.basename(theInputDB), 1, len(dSDMCounts), 1)
tblList = sorted(dSDMCounts)
for tbl in tblList:
arcpy.SetProgressorLabel(tbl)
sdmCnt = dSDMCounts[tbl]
if arcpy.Exists(tbl):
gdbCnt = int(arcpy.GetCount_management(os.path.join(theInputDB, tbl)).getOutput(0))
else:
raise MyError, "Missing table (" + tbl+ ") in " + os.path.basename(theInputDB)
badCount.append((os.path.join(theInputDB, tbl), 0, sdmCnt))
dGDBCounts[tbl] = gdbCnt
arcpy.SetProgressorPosition()
if sdmCnt != gdbCnt:
if sdmCnt == -1:
# SDA query failed to get count for this table
badCount.append((tbl, 0, gdbCnt, gdbCnt))
else:
# Record counts do not agree
badCount.append(( tbl, sdmCnt, gdbCnt, (sdmCnt - gdbCnt) ))
if len(badCount) > 0:
PrintMsg("\t\tDiscrepancy found in table counts:", 2)
PrintMsg(" \nTABLE, SDM, GDB, DIFF", 0)
for tbl in badCount:
PrintMsg(tbl[0] + ", " + str(tbl[1]) + ", " + str(tbl[2]) + ", " + str(tbl[3]), 0)
arcpy.SetProgressorLabel("")
arcpy.ResetProgressor()
if len(badCount) > 0:
return False
else:
return True
except MyError, e:
# Example: raise MyError, "This is an error message"
PrintMsg(str(e), 2)
return False