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.
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..
Thank you so much for your response, however i am not getting the kml file. For some reason its not being saved. please assist
# 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")