I'm trying to save the raster layer in the stand-alone python GUI but I keep getting a syntax error.
I'm using the code from Save To Layer File (Data Management). And the error that shows up is: the LA MESA part of below:
in_features = "spain_1901_1.shp"out_layer0 = "spain_1901_1"where_clause = '"NAME" = 'LA MESA''workspace = "C:/output"now I've replaced their fill in things from the website with what I need but I keep getting an error saying that LA MESA isn't the correct syntax even when I replace it with my own name.
please help!
EDIT: Here's the entire code:
#MAKE RASTER FILE# Import system modulesimport arcpy# Set local variablesinNetCDFFile = "C:/Users/ESS/Desktop/temp/tmpy1901m01.nc"variable = "tmp"XDimension = "lon"YDimension = "lat"outRasterLayer = "C:/Users/ESS/Desktop/out/spain_1901_1.shp"bandDimmension = ""dimensionValues = ""valueSelectionMethod = ""# Execute MakeNetCDFRasterLayerarcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension, outRasterLayer, bandDimmension, dimensionValues, valueSelectionMethod)#SAVE IT!!!!!!# Name: SaveToLayerFile_Example2.py# Description: Saves an inMemory layer to a file on disk# Author: ESRI# Import system modulesimport arcpyfrom arcpy import env# Set workspaceenv.workspace = "C:/Users/ESS/Desktop/out"# Set local variablesin_layer = "spain_1901_1"out_layer = "spain_1901_1.lyr"#MakeFeatureLayer variablesin_features = "spain_1901_1.shp"out_layer0 = "spain_1901_1"where_clause = '"NAME" = \'LA MESA\''workspace = "C:/Users/ESS/Desktop/out"try: # Execute MakeFeatureLayer arcpy.MakeFeatureLayer_management(in_features, out_layer0, where_clause, workspace) # Execute SaveToLayerFile arcpy.SaveToLayerFile_management(in_layer, out_layer, "ABSOLUTE")except: print arcpy.GetMessages()##THE CALCULATIONS # Import system modulesimport arcpyfrom arcpy import envfrom arcpy.sa import *# Set environment settingsenv.workspace = "C:/Users/ESS/Desktop/out"# Set local variablesinZoneData = "es2001.shp"zoneField = "FIDS"inValueRaster = "spain_1901_1"outTable = "spain_1901_1_data.dbf"# Check out the ArcGIS Spatial Analyst extension licensearcpy.CheckOutExtension("Spatial")# Execute ZonalStatisticsAsTableoutZSaT = ZonalStatisticsAsTable(inZoneData, zoneField, inValueRaster, outTable, "NODATA", "ALL")
أكثر...
I'm using the code from Save To Layer File (Data Management). And the error that shows up is: the LA MESA part of below:
in_features = "spain_1901_1.shp"out_layer0 = "spain_1901_1"where_clause = '"NAME" = 'LA MESA''workspace = "C:/output"now I've replaced their fill in things from the website with what I need but I keep getting an error saying that LA MESA isn't the correct syntax even when I replace it with my own name.
please help!
EDIT: Here's the entire code:
#MAKE RASTER FILE# Import system modulesimport arcpy# Set local variablesinNetCDFFile = "C:/Users/ESS/Desktop/temp/tmpy1901m01.nc"variable = "tmp"XDimension = "lon"YDimension = "lat"outRasterLayer = "C:/Users/ESS/Desktop/out/spain_1901_1.shp"bandDimmension = ""dimensionValues = ""valueSelectionMethod = ""# Execute MakeNetCDFRasterLayerarcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension, outRasterLayer, bandDimmension, dimensionValues, valueSelectionMethod)#SAVE IT!!!!!!# Name: SaveToLayerFile_Example2.py# Description: Saves an inMemory layer to a file on disk# Author: ESRI# Import system modulesimport arcpyfrom arcpy import env# Set workspaceenv.workspace = "C:/Users/ESS/Desktop/out"# Set local variablesin_layer = "spain_1901_1"out_layer = "spain_1901_1.lyr"#MakeFeatureLayer variablesin_features = "spain_1901_1.shp"out_layer0 = "spain_1901_1"where_clause = '"NAME" = \'LA MESA\''workspace = "C:/Users/ESS/Desktop/out"try: # Execute MakeFeatureLayer arcpy.MakeFeatureLayer_management(in_features, out_layer0, where_clause, workspace) # Execute SaveToLayerFile arcpy.SaveToLayerFile_management(in_layer, out_layer, "ABSOLUTE")except: print arcpy.GetMessages()##THE CALCULATIONS # Import system modulesimport arcpyfrom arcpy import envfrom arcpy.sa import *# Set environment settingsenv.workspace = "C:/Users/ESS/Desktop/out"# Set local variablesinZoneData = "es2001.shp"zoneField = "FIDS"inValueRaster = "spain_1901_1"outTable = "spain_1901_1_data.dbf"# Check out the ArcGIS Spatial Analyst extension licensearcpy.CheckOutExtension("Spatial")# Execute ZonalStatisticsAsTableoutZSaT = ZonalStatisticsAsTable(inZoneData, zoneField, inValueRaster, outTable, "NODATA", "ALL")
أكثر...