我正在使用以下功能:
def LAS2TXTGridClip(inFile,poly,MinPoints=1):
sf = shapefile.Reader(poly) #open shpfile
sr = sf.shapeRecords()
poly_filename, ext = path.splitext(poly)
inFile_filename = os.path.splitext(os.path.basename(inFile))[0]
for i in xrange(len(sr)):
verts = np.array(sr[i].shape.points,float)
record = sr[i].record[0]
inside_points = [p for p in lasfile.File(inFile,None,'r') if pnpoly(p.x, p.y, verts)]
if len(inside_points) >= MinPoints:
file_out = open("{0}_{1}_{2}.txt".format(poly_filename, inFile_filename, record), "w")
for p in inside_points:
file_out.write("%s %s %s %s %s %s %s %s %s %s %s" % (p.x, p.y, p.z, p.intensity,p.return_number,p.number_of_returns,p.scan_direction,p.flightline_edge,p.classification,p.scan_angle,record)+ "\n")
file_out.close()
where for i in xrange(len(sr)):
该函数将被处理多次。 len(sr)
约为 50 万,我希望插入一个进度条,以便了解我需要等待的时间(今天是星期五)。我有以下问题:
- 哪个是 Windows 操作系统上 python 27 的“最好、最简单”的进度条 64位?
- 我发现progressbar module但我使用时遇到问题 此步骤之后的 easy_install 进度条。
- 插入进度条的最佳位置在哪里?
最佳答案
您在使用模块progressbar
时遇到什么问题?这是非常好的解决方案。
$ cd progressbar-2.2/
$ sudo python setup.py install
...blablabla...
$ python
>>> from progressbar import ProgressBar
>>> pbar = ProgressBar(10)
>>> for i in range(10):
... pbar.update(i+1)
...
100% |######################################################################|
关于Python:如何在我的函数中使用进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12859253/