I am trying to write a script that pans to every point of layer, creates a temporal buffer to "highlight" point and exports the image. I want buffer to be deleted after every loop run, so I can use the same name again. Using that symbology that I have chosen is loaded for buffer. Here is the code:

import arcpy
import os
from arcpy import mapping

def point_coords_to_extent(point_coords): 
    extent = arcpy.Extent(point_coords[0], point_coords[1], point_coords[0], point_coords[1])
    return extent

mxd = mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames(mxd)[0]
out_folder = r"C:\Users\Me\Desktop\export"
with arcpy.da.SearchCursor("ALEJA_test", ["SHAPE@XY","adr_for","nazwa", "OID@", "SHAPE@"]) as cursor:
    for row in cursor:
        if row[1] not in (""," "): 
            arcpy.Buffer_analysis(row[4], "BUFFER_HIGHLIGHT", "30 Meters")

            arcpy.mapping.ExportToPNG(mxd, out_folder + "\\" + str(row[1][8:]) + "_" + row[2] + "#"+ str(row[3]) +'.png', resolution = 300)

The problem is that when I use it as a script tool I get properly exported zoomed images, however there is no buffer. When I paste it directly to Python window in ArcMap, after first export I get the error that "BUFFER_HIGHLIGHT" already exists.

Does anyone has an idea how to fix it? (script tool is my aim)

EDIT: Instead of deleting buffer I 've set arcpy.env.overwriteOutput = True and it works fine BUT only in Python window. Why it is not generating the same in script tool? What is the difference?

  • why not use symbology ?
    – radouxju
    Jan 10, 2017 at 12:36
  • Unfortunatelly, symbology must remain unchanged. Also, it is just a part of the main script in which it goes through few layers.
    – Kubson
    Jan 10, 2017 at 12:43
  • you could use a specific symbology for the point on which you are zooming and add this point on top of the other layer. Or you could define a symbol for selected points and select the point on which you are zooming. Or you could make a buffer around all points and use a definition query to show just one buffer. Of course, if you need to use the buffer, then symbology is not enough but you didn't mention that constraint
    – radouxju
    Jan 10, 2017 at 13:03
  • I don't really understand the first solution you mentioned. Could you explain it more? Defining symbol for selection would require changing the symbol and starting script again for every layer and there is quite a few of them. Making buffer for all and the definition query seems good, but requires quite complicated preparation of buffer layer (or layers, because for every layer?). If I won't find out why my script is not working I will probably use that, but I would prefer to keep it as simple as possible.
    – Kubson
    Jan 10, 2017 at 13:18
  • Data driven pages do it with ease, use match/don't match pages definition query
    – FelixIP
    Jan 10, 2017 at 19:25

1 Answer 1


Can you make a copy the points layer and then symbolize the features using ground units?

Then it will be like radouxju suggested and instead of creating a buffer for each point feature you change the definition query per feature and here is another example using numbers.

  • That way I will not be able to create circles (empty polygons). Also, this solution seems similar to radouxju`s one with its complexity and I would prefer simplier way.
    – Kubson
    Jan 10, 2017 at 15:00
  • Circles? Your symbology can be a hollow fill with a solid border - that is a circle. Good luck, however you achieve it.
    – Barrett
    Jan 10, 2017 at 15:07
  • Oh, ok you are right! That can be useful, up for you. However, I still would like to know why my solution doesn't work as a tool but works in console.
    – Kubson
    Jan 11, 2017 at 7:35

Your Answer

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

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