Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am iterating over a shapefile and creating a new shape from each row. I will be creating several thousand individual shapes and do not want to inundate my TOC with that many layers (I bet ArcMap would crash if I did). Using the code below, each shape is added after being created. How could I remove the shape from the TOC after being created? I tried deleting the tempPoly variable but that did not do the trick.

polys = arcpy.SearchCursor(shapefile) #recall the cursor
for poly in polys: 
    print('starting at '+str(poly.FID))
    whereClause = '"FID" = ' + str(poly.FID     ) # Create a clause to select only the current record

I am not working in a dataframe and am in the data view not the layout view.

share|improve this question
up vote 3 down vote accepted

You have three options here:

  1. Un-check the Add results of geoprocessing operations to display check box (Geoprocessing menu>Geoprocessing Options)

  2. By code, use the arcpy RemoveLayer() method.

  3. Also by code, use the arcpy Delete (Data Management) Geoprocessing function to remove the layer by name.

share|improve this answer

Are these polygons features (it appears they are)? Is there a unique field of type "Text" (something other than FID)?

If so, you could also just use the Split_Analysis tool, and use the featureclass as both the input features and split features, the "Text" field as the split field, and then define your target workspace.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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