0

I have to make multibuffer to a several shp's (30 or +) and with this code the it takes 30 minutes or more.

    import arcpy,time,glob,os
def multibuffer (probe,Zona_trab,nombarch3,recortes2):
    x=0
    bufdef = (Zona_trab,"\\bufferRing",time.strftime("%H%M%S"),".shp")
    bufferRings = ''.join(bufdef)
    if probe == 1:
        with open (nombarch3) as p:
            for x in recortes2:
                dtaring = p.readline()
                arquet, valbuf2, datperm= dtaring.split(",")
                valbuf2=float(valbuf2)
                a= valbuf2*0.3
                b= valbuf2*0.5
                c= valbuf2
                distances = [a,b,c]
                puntselec1a2 = (Zona_trab,"\\puntsele",x,".shp")
                puntsele2 = ''.join(puntselec1a2)
                print puntsele2
                print distances
                arcpy.MultipleRingBuffer_analysis(puntsele2,"capadeRingbuff"+str(x)+".shp", distances, "meters", "", "ALL") 
        p.close
        wcard="puntsele*"
        try:
            dir=Zona_trab+os.sep+wcard+'.shp'
            flist=glob.glob(dir)
            arcpy.Merge_management(flist, bufferRings)
        except:
            print "error"

The code works, it have no errors, so it will work slow, but safe. My question is:

what would you do for speed up the process?


The first part of the program is done instantly, but this call:

arcpy.MultipleRingBuffer_analysis(puntsele2,"capadeRingbuff"+str(x)+".shp", distances, "meters", "", "ALL") 

Make the stop of several minutes in the script.

With this new info, someone know how to speed up this part? Doing several MultipleRingBuffer at once or something like that? (I think is not posible to make that)

  • Have you done some performance timing? I suspect that you will find the Multiple Ring Buffer tool to be consuming far more time than your ArcPy code. – PolyGeo Feb 17 '15 at 11:12
  • Making the first part its quick, but the arcpy.MultipleRingBuffer_analysis(puntsele2,"capadeRingbuff"+str(x)+".shp", distances, "meters", "", "ALL")its too slow. There are some ways to make this faster or that is the limit? – Gsanez Feb 17 '15 at 12:29
  • 1
    As you are calling an existing tool you don't have any control of what is going on inside it. The only thing I can think of that could improve performance is to write the output Feature Class to an in_memory workspace then merge those. – Hornbydd Feb 17 '15 at 15:21
  • Please use the edit button to provide clarifications to your question. – PolyGeo Feb 17 '15 at 20:13
1

Since the performance that you are observing seems to be down to one particular tool, Multiple Ring Buffer, which is a Python script tool, I think you should submit an ArcGIS Idea to have it re-written at a lower level to improve its performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.