1

I need to make 500m rings (not full circle) around points (cities). I try to make 1. buffer: 2500 - 8500m (each 500m) and second buffer 3000 - 9000 (each 500m) and then erase 2500m from 3000m, 3000m (1.st buffer) from 3500m (second buffer), ... to get those 500m rings. But everytime i get an error.

import arcpy.sa
... k = 3000
... while k<=9000:
...     arcpy.Buffer_analysis("sidla","sidlaBuff"+str(k),k)
...     k=k+500
... l = 2500
... while l<=8500:
...     arcpy.Buffer_analysis("sidla","vyrezBuff"+str(l),l)
...     l=l+500
arcpy.Erase_analysis("sidlaBuff"+str(k),"vyrezBuff"+str(l),"vysledek"+str(l))

The error is something about that it can't do the layer sidlaBuff9500 and vyrezBuff9000, but those layers i dont want to do... but if i run that code WITHOUT the Erase, all buffer run correctly. Can anyone help?

  • could you tag this with a less general tag than python in addition? This seems to be arcpy, so tag accordingly – atlefren Jan 19 '15 at 8:28
  • 1
    Why don't you just use the Multiple Ring Buffer tool? – GISGe Jan 19 '15 at 8:57
  • Are you trying to make bands ('donuts') around your city, with each donut being 500m wide, ie, Donut1 is 2500-3000? – Mox Jan 19 '15 at 19:05
1

K and L are held in memory after your script runs. The last K and L will be 9500 and 9000, respectively, as your error suggests because after each buffer it adds 500 to the value of these variables and your erase is only calling the last value as it is outside of the WHILE loop. I would create another iterator and put erase inside of it to function after each run of K and L so that it is processed while valid K and L values are still in memory.

0

Your double 'while' may be the cause. Rather than use two iterators, k and l, just use one. Let i = iteration count. i=0 while i<20 Buffer1=2500+500*i Buffer2=3000+500*i Buffer2-Buffer1=Result i=i+1

0

first, you don't need spatial analyst for this

second, you could have used multiple ring buffer for doing that, but I assume that you need all intermediate feature classes

third, there are some indentation issues in your code

import arcpy
... k = 2500
... while k<=8500:
...     arcpy.Buffer_analysis("sidla","sidlaBuff"+str(k),k)
...     arcpy.Buffer_analysis("sidla","vyrezBuff"+str(k+500),k+500)
...     arcpy.Erase_analysis("vyrezBuff"+str(k+500),"sidlaBuff"+str(k),"vysledek"+str(k))
...     k+=500

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.