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

With Python, how do I get either the MakeXYEventLayer_management or the MakeFeatureLayer_management layer that is temporarily created added to ArcMap automatically after the tool is run, without using arcpy.mapping?

share|improve this question
up vote 2 down vote accepted

Add an output parameter of type Feature Layer to your tool. Set its value to the name of the XY Layer you make with the tool at the end of your script. This lets the geoprocessing framework know that you really meant to make that layer permanent (and not just as intermediate data) and to add it to the table of contents.

share|improve this answer
Thanks. I got it figured out. Is there anything wrong with adding features to ArcMap when they are in memory? I notice when I go to the data sources tab, it says the layer is from GPInMemoryWorkspace:{...}. Is there anything technically wrong with doing this, like is it bad form? – ianbroad Sep 18 '13 at 22:40
Just be aware that they won't persist to disk, so if you save out an MXD that has layers with in memory feature classes they'll be empty the next time you open the document. In memory feature classes are super nice in that they're really fast since Arc* doesn't have to touch the disk/network to access them. – Jason Scheirer Sep 18 '13 at 22:44
Yeah, this is definitely a layer that doesn't need to be saved, we just need to see it once. I noticed that I can't add arcpy.Delete_management(layer) to the end of my script because obviously the layer I add to ArcMap is then empty. This doesn't cause some type of memory issue by not deleting it, right? Just when ArcMap closes, the memory is then removed? – ianbroad Sep 18 '13 at 22:46
Yeah, the memory gets freed when you manually delete the layer from the table of contents or when ArcMap closes. – Jason Scheirer Sep 18 '13 at 22:50
Awesome, thanks for your assistance. – ianbroad Sep 18 '13 at 22:51

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.