當前位置: 首頁>>代碼示例>>Python>>正文


Python arcpy.SetProgressor方法代碼示例

本文整理匯總了Python中arcpy.SetProgressor方法的典型用法代碼示例。如果您正苦於以下問題:Python arcpy.SetProgressor方法的具體用法?Python arcpy.SetProgressor怎麽用?Python arcpy.SetProgressor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在arcpy的用法示例。


在下文中一共展示了arcpy.SetProgressor方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_cls_boundary

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import SetProgressor [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 
開發者ID:lopp2005,項目名稱:HiSpatialCluster,代碼行數:27,代碼來源:section_cpu.py

示例2: GetFieldInfo

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import SetProgressor [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()

## =================================================================================== 
開發者ID:ncss-tech,項目名稱:geo-pit,代碼行數:42,代碼來源:SSURGO_CheckgSSURGO2.py

示例3: calc_density_cpu

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import SetProgressor [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) 
開發者ID:lopp2005,項目名稱:HiSpatialCluster,代碼行數:44,代碼來源:section_cpu.py

示例4: calc_nrst_dist_cpu

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import SetProgressor [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)) 
開發者ID:lopp2005,項目名稱:HiSpatialCluster,代碼行數:47,代碼來源:section_cpu.py

示例5: GetGDBCount

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import SetProgressor [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 
開發者ID:ncss-tech,項目名稱:geo-pit,代碼行數:58,代碼來源:SSURGO_CheckgSSURGO2.py

示例6: GetGDBCount

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import SetProgressor [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 
開發者ID:ncss-tech,項目名稱:geo-pit,代碼行數:58,代碼來源:SSURGO_CheckgSSURGO.py


注:本文中的arcpy.SetProgressor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。