Create a Export to KMZ Web Tool

720
3
01-21-2022 12:04 PM
CHedger1227
New Contributor III

Hello,

I am trying to create a web  tool that will allow my users (AGOL users) to export a selected feature to a KMZ file. I have it working for the most part but I think i am doing something wrong. The code i am using works (Python) but when i publish it up to ArcServer i am looking for it to give me the layers of the map they are currently on. This part I am not getting to show up correctly. What it is doing right now is it gives me the drop down of the object that i ran the tool with, (Even though I ran it with the parameter input feature of User Defined Value). I want to have the option of my current map as the options.

The process i am doing to publish is Share as on my ArcGIS Enterprise connection > Share as geoprocessing service > select my recently ran tool> name everything accordingly> go into content > input mode i am setting to user defined value and publishing. 

what am I doing wrong? Does this make sense as to what I am looking for?

Python Script:

# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2022-01-21 10:57:50
"""
import arcpy
from sys import argv

def Model(Input_Feature, Output_File): # ExportToKMZ

# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False


# Process: Make Feature Layer (Make Feature Layer) (management)
Output_Layer = Output_File
arcpy.management.MakeFeatureLayer(in_features=Input_Feature, out_layer=Output_Layer, where_clause="", workspace="", field_info="")

# Process: Layer To KML (Layer To KML) (conversion)
arcpy.conversion.LayerToKML(layer=Output_Layer, out_kmz_file=Output_File, layer_output_scale=0, is_composite="NO_COMPOSITE", boundary_box_extent="DEFAULT", image_size=1024, dpi_of_client=96, ignore_zvalue="CLAMPED_TO_GROUND")

if __name__ == '__main__':
Model(*argv[1:])

 

Thank you
0 Kudos
3 Replies
SzuNyiapTang
Esri Contributor

Hi @CHedger1227 

Did you try the analysis tool in Map Viewer Classic?

Extract Data—ArcGIS Online Help | Documentation

Cheers,

Tang

Cheers,
Tang
0 Kudos
CHedger1227
New Contributor III

Tang,

Thanks for reaching out. Yes I did the client I am doing this for does not like the way that the data extraction works. It is too many clicks and too clunky. They are not very familiar with GIS so the less clicks the better. This way also uses up credits which they do not have many of so there are a lot of things they do not like about the extract data tool. 

Thank you
0 Kudos
GdB_Admin
New Contributor III

i too would like to know how to do this

Thank you for your time on this. Please let me know if you have any questions
0 Kudos