2

我正在使用以下功能:

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()

for i in xrange(len(sr)):函数将被处理多次。大约是 50 万,len(sr)我希望插入一个进度条,以便了解我需要等待的时间(现在是星期五)。我有以下问题:

  1. 哪个是 Windows OS 64 位上 python 27 的“最佳和简单”进度条?
  2. 我找到了进度条模块,但在这一步之后我无法使用 easy_install 进度条。
  3. 插入进度条的最佳位置在哪里?
4

1 回答 1

4

您对模块有什么问题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% |######################################################################|
于 2012-10-12T12:53:57.100 回答