Convert selected features to kml

640
5
09-25-2019 04:38 AM
OlindaMombeyarara
New Contributor II

hi,

May you please assist me with my model builder, so basically i have 15 layers and i would like to select layers by certain attributes  first and then convert the selected attributes to kml without having to export the selected features to a feature class. However i cannot get this to work as all the features are being converted to kml instead of the selected features only am i suppose to add some extra code or what.

i do not want to export the selected features as that would create a lot of layers and it will become messy.

0 Kudos
5 Replies
LeoLiu1
Occasional Contributor

Hi Olinda,

Try this way: use Copy Features tool to copy your selected features into a temp feature class, then Make Feature Layer by the temp feature class, and then Layer To KML tool.

The Copy Features tool will pick up selected features only if the input is a layer and has a selection..

0 Kudos
OlindaMombeyarara
New Contributor II

Thank you so much for your response, however i am not getting the kml file. For some reason its not being saved. please assistmodel image

import arcpy

# To allow overwriting the outputs change the overwrite option to true.
arcpy.env.overwriteOutput = False

# Local variables:
Residential__2_ = "Residential"
Residentialbyattribute = Residential__2_
Count = "7"
ResCopiedFeatures = r"C:\Users\SADV\Work\Esri Data\2018\SADV_Res_Coverage\SADV_Res_Coverage.gdb\ResCopiedFeatures"
ResCopiedFeatures_Layer = "ResCopiedFeatures_Layer"
residentialtest_kmz = r"C:\Users\SADV\Documents\ArcGIS\testing\residentialtest.kmz"

# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(in_layer_or_view=Residential__2_, selection_type="NEW_SELECTION", where_clause="BuildStatus = 'In Progress' And Province = 'WC'", invert_where_clause="")

# Process: Copy Features
arcpy.CopyFeatures_management(in_features=Residentialbyattribute, out_feature_class=ResCopiedFeatures, config_keyword="", spatial_grid_1="", spatial_grid_2="", spatial_grid_3="")

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(in_features=ResCopiedFeatures, out_layer=ResCopiedFeatures_Layer, where_clause="", workspace="", field_info="OBJECTID OBJECTID VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;Name Name VISIBLE NONE;FolderPath FolderPath VISIBLE NONE;GlobalID GlobalID VISIBLE NONE;Open_Access Open_Access VISIBLE NONE;Status Status VISIBLE NONE;Installation_Fee Installation_Fee VISIBLE NONE;Promotional_Products Promotional_Products VISIBLE NONE;SHAPE_Length SHAPE_Length VISIBLE NONE;SHAPE_Area SHAPE_Area VISIBLE NONE;Site_Account_ID Site_Account_ID VISIBLE NONE;Unique_ID Unique_ID VISIBLE NONE;BuildStatus BuildStatus VISIBLE NONE;Province Province VISIBLE NONE")

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Did it exist from a previous test?  If so, arcpy.env.overwriteOutput = False means it won't produce a new output

0 Kudos
OlindaMombeyarara
New Contributor II

it hasnt worked at all so there is nothing at all, no previous test

0 Kudos
LeoLiu1
Occasional Contributor

Hi Olinda,

Has the selection been copied into your temp feature class? or any message in results window?

0 Kudos