Python Toolbox Float Layer Data Type naming issue

المشرف العام

Administrator
طاقم الإدارة
I am creating a python toolbox, and I have been experiencing some issues with rasters not being in float format. So I used the Raster to Float tool to convert it, and now that it is converted, I need a way for my python toolbox to recognize the new layer that is a .FLT file. Attached is my code, with '!!!!!!!' in place of the area that I am trying to update within the parameters. The parameter that needs updated is param2. I do not know what to name the datatype now to recognize the float layer.

import arcpyimport mathclass Toolbox(object): def __init__(self): """Define the toolbox (the name of the toolbox is the name of the .pyt file).""" self.label = "Toolbox Label Property" self.alias = "Toolbox Alias Property" # List of tool classes associated with this toolbox self.tools = [FSPL, WAP_Buffer]class FSPL(object): def __init__(self): """Define the tool (tool name is the name of the class).""" self.label = "Free Space Path Loss" self.description = "This python script tool will create Free Space Path Loss to determine the dB range output from the WAPs." self.canRunInBackground = Falsedef getParameterInfo(self): """Define parameter definitions""" param0 = arcpy.Parameter( displayName="Wireless Access Points", name="wireless_pts", datatype="GPFeatureLayer", parameterType="Required", direction="Input") param1 = arcpy.Parameter( displayName="Network Frequency Type", name="network_freq", datatype="String", parameterType="Required", direction="Input") param1.filter.type="ValueList" param1.filter.list = ["2.4 GHz", "5 GHz"] param2 = arcpy.Parameter( displayName="Distance Raster Float", name="dist_float", datatype="!!!!!!!!!", parameterType="Required", direction="Input") param3 = arcpy.Parameter( displayName="Distance Raster Units", name="units", datatype="String", parameterType="Required", direction="Input") param3.filter.type="ValueList" param3.filter.list = ["Feet", "Meters"] param4 = arcpy.Parameter( displayName="Output Raster", name="output_rast", datatype="GPRasterLayer", parameterType="Required", direction="Output") return [param0, param1, param2, param3, param4]def isLicensed(self): """Set whether tool is licensed to execute.""" return Truedef updateParameters(self, parameters): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parameter has been changed.""" returndef updateMessages(self, parameters): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" returndef execute(self, parameters, messages): """The source code of the tool.""" #Get inputs wireless_pts = parameters[0].value network_freq = parameters[1].value dist_float = parameters[2].value units = parameters[3].value output_rast = parameters[4].value shapeFieldName = arcpy.Describe(wireless_pts).shapeFieldName #Create expression if network_freq == "2.4 GHz": hertz=2400000000 else: hertz=5000000000 if units == "Feet": distmod=0.3048 else: distmod=1 #equation fspl= (4 * math.pi * distmod * dist_float * hertz)/(2.99792458 * (10**8)) output_rast = fspl return Also If anyone finds any other issues with how I am trying to call these at the end, I would appreciate any help fixing that. The end result I want with this particular tool is to create a raster that is populated with the FSPL equation.



أكثر...
 
أعلى