Taking KMZs as input parameters won't work.

403
1
12-19-2022 02:03 PM
rescobar
New Contributor III

Hello,

My second get parameter as text isn't working. Once I load the script in pro, if I set the parameter to be a 'kml layer' it says the kmz files are unsupported. If I try just 'file' this also returns an error. What should I set this parameter to take as input? Thank you.

 

# Import the necessary modules
import arcpy
# Set the workspace
arcpy.env.workspace = arcpy.GetParameterAsText(0)
# Get the input KML file and output layer name
input_kml = arcpy.GetParameterAsText(1)
output_layer = arcpy.GetParameterAsText(2)
# Convert the KML to a layer
arcpy.KMLToLayer_conversion(input_kml, arcpy.env.workspace, output_layer)
# Get the output projected layer name and the projection information
output_projected_layer = arcpy.GetParameterAsText(3)
projection_info = arcpy.GetParameterAsText(4)
# Project the layer
arcpy.Project_management(output_layer, output_projected_layer, projection_info)
# Print a success message
print("Successfully converted KML to layer and projected it")

 

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

 

 

You might try text/string to specify the output name (text)

output_name = arcpy.GetParameterAsText(2)

output_layer = rf"{arcpy.env.workspace}\\{output_name}

 

 


... sort of retired...
0 Kudos