I'm currently studying for a Msc in GIS. In my assignment I have been asked to produce a model, export that model as a script file and then run that script as a stand alone in IDLE. So I have created the model in model builder and exported it as a script and have even had a go at cleaning the script. But whenever I try to run the script I get an error. I have attached a jpeg of my model and have also attached the script file. Does anyone know where I'm going wrong? Im using Arcmap 10.1 and python 3.4
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # floodrisk.py # Created on: 2014-04-21 11:34:26.00000 # (generated by ArcGIS/ModelBuilder) # Usage: floodrisk # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy arcpy.env.workspace = "C:\Users\Imran\Documents\MASTER GIS\ASSIGNMENT4\Floodrisk.gdb" arcpy.env.overwriteOutput = True # Script arguments River_thames = arcpy.GetParameterAsText(0) if River_thames == '#' or not River_thames: River_thames = "River_thames.shp" # provide a default value if unspecified POI = arcpy.GetParameterAsText(1) if POI == '#' or not POI: POI = "POI.shp" # provide a default value if unspecified SOA = arcpy.GetParameterAsText(2) if SOA == '#' or not SOA: SOA = "SOA.shp" # provide a default value if unspecified POI_clipped = arcpy.GetParameterAsText(3) if POI_clipped == '#' or not POI_clipped: POI_clipped = "POI_clipped.shp" # provide a default value if unspecified SOA_clipped__6_ = arcpy.GetParameterAsText(4) if SOA_clipped__6_ == '#' or not SOA_clipped__6_: SOA_clipped__6_ = "SOA_clipped.shp" # provide a default value if unspecified # Local variables: River_thames_buffer1 = "River_thames.shp" SOA_clipped = "River_thames_buffer1.shp" SOA_clipped__2_ = "SOA_clipped.shp" SOA_clipped__3_ = "SOA_clipped__2_.shp" SOA_clipped__4_ = "SOA_clipped__3_.shp" SOA_clipped__5_ = "SOA_clipped__4_.shp" # Process: Buffer arcpy.Buffer_analysis(River_thames, River_thames_buffer1, "300 Meters", "FULL", "ROUND", "NONE", "") # Process: Clip arcpy.Clip_analysis(POI, River_thames_buffer1, POI_clipped, "") # Process: Clip (2) arcpy.Clip_analysis(SOA, River_thames_buffer1, SOA_clipped, "") # Process: Add Field arcpy.AddField_management(SOA_clipped, "AreaB", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") # Process: Calculate Field arcpy.CalculateField_management(SOA_clipped__2_, "AreaB", "!shape.area! ", "PYTHON", "") # Process: Calculate Field (2) arcpy.CalculateField_management(SOA_clipped__3_, "AreaB", "[AreaB]/1000000", "VB", "") # Process: Add Field (2) arcpy.AddField_management(SOA_clipped__4_, "areaP", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") # Process: Calculate Field (3) arcpy.CalculateField_management(SOA_clipped__5_, "areaP", "[AreaB]/ [AreaSQKM]", "VB", "")
أكثر...
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # floodrisk.py # Created on: 2014-04-21 11:34:26.00000 # (generated by ArcGIS/ModelBuilder) # Usage: floodrisk # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy arcpy.env.workspace = "C:\Users\Imran\Documents\MASTER GIS\ASSIGNMENT4\Floodrisk.gdb" arcpy.env.overwriteOutput = True # Script arguments River_thames = arcpy.GetParameterAsText(0) if River_thames == '#' or not River_thames: River_thames = "River_thames.shp" # provide a default value if unspecified POI = arcpy.GetParameterAsText(1) if POI == '#' or not POI: POI = "POI.shp" # provide a default value if unspecified SOA = arcpy.GetParameterAsText(2) if SOA == '#' or not SOA: SOA = "SOA.shp" # provide a default value if unspecified POI_clipped = arcpy.GetParameterAsText(3) if POI_clipped == '#' or not POI_clipped: POI_clipped = "POI_clipped.shp" # provide a default value if unspecified SOA_clipped__6_ = arcpy.GetParameterAsText(4) if SOA_clipped__6_ == '#' or not SOA_clipped__6_: SOA_clipped__6_ = "SOA_clipped.shp" # provide a default value if unspecified # Local variables: River_thames_buffer1 = "River_thames.shp" SOA_clipped = "River_thames_buffer1.shp" SOA_clipped__2_ = "SOA_clipped.shp" SOA_clipped__3_ = "SOA_clipped__2_.shp" SOA_clipped__4_ = "SOA_clipped__3_.shp" SOA_clipped__5_ = "SOA_clipped__4_.shp" # Process: Buffer arcpy.Buffer_analysis(River_thames, River_thames_buffer1, "300 Meters", "FULL", "ROUND", "NONE", "") # Process: Clip arcpy.Clip_analysis(POI, River_thames_buffer1, POI_clipped, "") # Process: Clip (2) arcpy.Clip_analysis(SOA, River_thames_buffer1, SOA_clipped, "") # Process: Add Field arcpy.AddField_management(SOA_clipped, "AreaB", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") # Process: Calculate Field arcpy.CalculateField_management(SOA_clipped__2_, "AreaB", "!shape.area! ", "PYTHON", "") # Process: Calculate Field (2) arcpy.CalculateField_management(SOA_clipped__3_, "AreaB", "[AreaB]/1000000", "VB", "") # Process: Add Field (2) arcpy.AddField_management(SOA_clipped__4_, "areaP", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") # Process: Calculate Field (3) arcpy.CalculateField_management(SOA_clipped__5_, "areaP", "[AreaB]/ [AreaSQKM]", "VB", "")

أكثر...