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?
1

1 Answer 1

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% |######################################################################|
Sign up to request clarification or add additional context in comments.

3 Comments

I am honest, i have a problem to use "easy_install progressbar"
just download and unpack .tar.gz archive and run python setup.py install into progressbar-2.2 folder (see answer update)
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.