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

What is the python Script for Shape file to Layer Conversion? I tried the following...

import arcpy  
from arcpy import env  
env.workspace="working path"  
arcpy.MakeFeatureLayer_conversion("source shapefile", "target name")
share|improve this question
arcpy.MakeFeatureLayer_management("source shapefile", "target name") – Paul Jun 26 '13 at 15:24
ok, i tried that also... – satya chandra Jun 26 '13 at 15:25
Could you please post the code that isn't working? It's working on my end. – Paul Jun 26 '13 at 15:29
import arcpy from arcpy import env env.workspace="G:/gis/test" arcpy.MakeFeatureLayer_management("india.shp","indlyr") – satya chandra Jun 26 '13 at 15:31
If you are doing this outside of ArcMap, then you need to save the layer to disk – Paul Jun 26 '13 at 15:36
up vote 4 down vote accepted

This should work...

import arcpy
from arcpy import env
env.workspace = "G:/gis/test"
dataset = arcpy.GetParameterAsText(0)
lyr = r'Path To output location' # e.g. r'C:\Mapping\IndiaLyr.Lyr'
arcpy.MakeFeatureLayer_management(dataset, "indlyr")
arcpy.SaveToLayerFile_management("indlyr", lyr, "ABSOLUTE")

Edited to accomodate script tool solution. You can probably get rid of the env.workspace variable as it won't be used.

Once you create the script tool from your script, right click the script tool and select properties.

Give your script tool a name...

enter image description here

Click the Parameters tab, give your input parameter a Display Name and select the data type you would like to use (if you expect to either use a shapefile, feature class, etc. use the Dataset data type)

enter image description here

Click finish. Now open your script tool by double clicking it or right clicking and selecting open. Browse or drag and drop your dataset.

enter image description here

share|improve this answer
+1 Quick and simple. Although env.worksapce has a spelling error. – Aaron Jun 26 '13 at 19:55
Thanks for pointing that out Aaron. – dchaboya Jun 26 '13 at 20:02
Now i want to make a simple tool from the above code?I tried to add this script file in tool box but i failed to set parameters?Please Explain? – satya chandra Jun 27 '13 at 4:57
What part of the help files have you read on creating tools before we replicate information you may already be familiar with? – Dan Patterson Jun 27 '13 at 17:01

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.