AnsweredAssumed Answered

Variable/GetParameterAsText() within expression

Question asked by tonalca6864 on Dec 17, 2014
Latest reply on Dec 18, 2014 by tonalca6864

Hi,

 

Please see code below.

 

I need to substitute the value "90" in Expression with user input, that is: LSARqssedret

 

I have tried: Expression = "!Qs_Mt_a!" * float(LSARqssedret) but I'm not getting the right syntax within the expression.

 

Any help would be greatly appreciated.

 

Many thanks

 

import arcpy
import string
import math
from arcpy import env
arcpy.env.overwriteOutput=True
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")

arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)

INWorkspace = arcpy.GetParameterAsText(0)

StageAge = "Maas"

LSARqssedret = arcpy.GetParameterAsText(1)

GridPoints_ft2_qs = (INWorkspace + "\\" + StageAge + "_nodes_variable_ft_2")

arcpy.AddField_management(GridPoints_ft2_qs,"MASS_g_a","DOUBLE")

Expression = "!Qs_Mt_a! * 90"

arcpy.CalculateField_management(GridPoints_ft2_qs,"Mass_g_a",Expression,"PYTHON")

Outcomes