Python arcpy.SetProgressorPosition() Examples
The following are 8
code examples of arcpy.SetProgressorPosition().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
arcpy
, or try the search function
.
Example #1
Source File: section_cpu.py From HiSpatialCluster with Apache License 2.0 | 10 votes |
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
Example #2
Source File: clean.py From Visualizing-Social-Media-Data with MIT License | 6 votes |
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()
Example #3
Source File: SSURGO_CheckgSSURGO2.py From geo-pit with GNU General Public License v2.0 | 5 votes |
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() ## ===================================================================================
Example #4
Source File: SSURGO_CheckgSSURGO.py From geo-pit with GNU General Public License v2.0 | 5 votes |
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() ## ===================================================================================
Example #5
Source File: section_cpu.py From HiSpatialCluster with Apache License 2.0 | 4 votes |
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)
Example #6
Source File: section_cpu.py From HiSpatialCluster with Apache License 2.0 | 4 votes |
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))
Example #7
Source File: SSURGO_CheckgSSURGO2.py From geo-pit with GNU General Public License v2.0 | 4 votes |
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
Example #8
Source File: SSURGO_CheckgSSURGO.py From geo-pit with GNU General Public License v2.0 | 4 votes |
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