2

I am using the following function:

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)): the function will be process several times. The len(sr) is around half million and I wish a insert a progress bar in order to have an idea of the time I need to wait (it's friday). I have the following question:

  1. Which is the "best and easy" progressbar for python 27 on windows OS 64bit?
  2. I found progressbar module but I have problem to use easy_install progressbar after this step.
  3. where is the best position to insert the progressbar?
jamessan
  • 41,569
  • 8
  • 85
  • 85
Gianni Spear
  • 7,033
  • 22
  • 82
  • 131

1 Answers1

4

What problems you are having with the module progressbar? It's very nice solution.

$ 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% |######################################################################|
defuz
  • 26,721
  • 10
  • 38
  • 60
  • I am honest, i have a problem to use "easy_install progressbar" – Gianni Spear Oct 12 '12 at 12:55
  • 2
    just download and unpack .tar.gz archive and run `python setup.py install` into `progressbar-2.2` folder (see answer update) – defuz Oct 12 '12 at 12:59
  • yes i understand where was my problem. After setup.py install, i i had tried to import progressbar with a error message. After that i closed and i opened again python and now i can import progressbar module – Gianni Spear Oct 12 '12 at 13:06