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.

I created a model in ModeBbuilder, and I exported the model as a script, but when I try to run it I get the following error. I have added my error below and the code below that. Thanks for any help.

Error: Traceback (most recent call last): File "C:\Temp\VirtualCampus\IGIS\IGISprogrammingscript_1.py", line 43, in arcpy.MakeFeatureLayer_management(Points_of_interest, Pointsofinterest_Layer, "", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;CATEGORY CATEGORY VISIBLE NONE;NAME NAME VISIBLE NONE")
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\management.py", line 5774, in MakeFeatureLayer raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000733: Output Layer: Same as input C:\Temp\VirtualCampus\IGIS\Super Output Areas.shp Failed to execute (MakeFeatureLayer).

Here is my code:

~# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# IGISprogrammingscript_1.py
# Created on: 2013-07-09 21:39:46.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: IGISprogrammingscript_1 <Thames_shp> <Points_of_interest> <Super_Output_Areas_shp> <Thames_Buffer_shp> <superoutputareas_clip_shp> 
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Script arguments
Thames_shp = arcpy.GetParameterAsText(0)
if Thames_shp == '#' or not Thames_shp:
    Thames_shp = "C:\\Temp\\VirtualCampus\\IGIS\\Thames.shp" # provide a default value if unspecified

Points_of_interest = arcpy.GetParameterAsText(1)
if Points_of_interest == '#' or not Points_of_interest:
    Points_of_interest = "Points of interest" # provide a default value if unspecified

Super_Output_Areas_shp = arcpy.GetParameterAsText(2)
if Super_Output_Areas_shp == '#' or not Super_Output_Areas_shp:
    Super_Output_Areas_shp = "C:\\Temp\\VirtualCampus\\IGIS\\Super Output Areas.shp" # provide a default value if unspecified

Thames_Buffer_shp = arcpy.GetParameterAsText(3)
if Thames_Buffer_shp == '#' or not Thames_Buffer_shp:
    Thames_Buffer_shp = "C:\\Temp\\VirtualCampus\\IGIS\\Thames_Buffer.shp" # provide a default value if unspecified

superoutputareas_clip_shp = arcpy.GetParameterAsText(4)
if superoutputareas_clip_shp == '#' or not superoutputareas_clip_shp:
    superoutputareas_clip_shp = "C:\\Temp\\VirtualCampus\\IGIS\\superoutputareas_clip.shp" # provide a default value if unspecified

# Local variables:
Pointsofinterest_Layer__2_ = Thames_Buffer_shp
poi_cat = Pointsofinterest_Layer__2_
poi_cat_View = poi_cat
Pointsofinterest_Layer = Points_of_interest
pop = superoutputareas_clip_shp
pop_View = pop

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(Points_of_interest, Pointsofinterest_Layer, "", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;CATEGORY CATEGORY VISIBLE NONE;NAME NAME VISIBLE NONE")

# Process: Buffer
arcpy.Buffer_analysis(Thames_shp, Thames_Buffer_shp, "300 Meters", "FULL", "ROUND", "NONE", "")

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(Pointsofinterest_Layer, "COMPLETELY_WITHIN", Thames_Buffer_shp, "", "NEW_SELECTION")

# Process: Summary Statistics
arcpy.Statistics_analysis(Pointsofinterest_Layer__2_, poi_cat, "CATEGORY COUNT", "CATEGORY")

# Process: Make Table View
arcpy.MakeTableView_management(poi_cat, poi_cat_View, "", "", "CATEGORY CATEGORY VISIBLE NONE;FREQUENCY FREQUENCY VISIBLE NONE;COUNT_CATEGORY COUNT_CATEGORY VISIBLE NONE")

# Process: Clip
arcpy.Clip_analysis(Super_Output_Areas_shp, Thames_Buffer_shp, superoutputareas_clip_shp, "")

# Process: Summary Statistics (2)
arcpy.Statistics_analysis(superoutputareas_clip_shp, pop, "LSOA_POP SUM", "")

# Process: Make Table View (2)
arcpy.MakeTableView_management(pop, pop_View, "", "", "Rowid Rowid VISIBLE NONE;FID FID VISIBLE NONE;FREQUENCY FREQUENCY VISIBLE NONE;SUM_LSOA_POP SUM_LSOA_POP VISIBLE NONE")~
share|improve this question

1 Answer 1

The parameters for MakeFeatureLayer are:

MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info})

Your parameters don't seem to fit into this format. perhaps try fixing it

arcpy.MakeFeatureLayer_management(Points_of_interest, Pointsofinterest_Layer, "", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;CATEGORY CATEGORY VISIBLE NONE;NAME NAME VISIBLE NONE")

not exactly sure what you are trying to get out of it.

does the line below fix your error?

arcpy.MakeFeatureLayer_management("Points_of_interest", "Pointsofinterest_Layer")
share|improve this answer
    
Hi, thanks for your help. I tried inputting your code, but it still produced the same error. I have three shapefiles, and am creating some new files from this, so a buffer, then using the buffer and one of the shapefiles to create a clip etc. I'm creating the model and then exporting the script, and running it in arc. The assignment is to create a model, export it as a python script, and import it as a script and in theory it should run like the model.... –  user19831 Jul 12 '13 at 21:52
    
Try removing this line: Pointsofinterest_Layer = Points_of_interest –  artwork21 Aug 11 '13 at 1:42

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.