Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question already has an answer here:

I have a toolbox with python script which creates a shapefile from JSON txt file, but it does not show the generated shapefile in arcmap, i have to add it from the output location.

What code shall I use to display this shapefile once it is created?

share|improve this question

marked as duplicate by PolyGeo Oct 13 at 4:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

There is a direct answer to your question on this link at StackOverflow:

How do I add a shapefile in ArcGIS via python scripting?

It is copied below with some modifications for clarity:

Variable "theShape" is the path of the shape file to be added.

import arcpy
import arcpy.mapping
# get the map document 
theShape = r"C:\Data\Environmental\Floodplain.shp"
mxd = arcpy.mapping.MapDocument("CURRENT")  

# get the data frame 
df = arcpy.mapping.ListDataFrames(mxd,"*")[0]  

# create a new layer 
newlayer = arcpy.mapping.Layer(theShape)  

# add the layer to the map at the bottom of the TOC in data frame 0 
arcpy.mapping.AddLayer(df, newlayer,"BOTTOM")

# Refresh things
del mxd, df, newlayer

Credit to @Tom-W for the answer.

share|improve this answer

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