Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 ran, without using arcpy.mapping?

I thought I had done this before, but I can't get it to work.

share|improve this question
add comment

1 Answer

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? –  ian 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? –  ian 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. –  ian Sep 18 '13 at 22:51
add comment

Your Answer

 
discard

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.