You need a script to select same colored features because the kml layer uses "Embedded Symbols" and the attribute table doesn't include any information about colors or polygons with same color.
- Open Python Editor (Ctrl+Alt+P then click middle icon)
- Select the layer and run this script.
# get active layer
layer = iface.activeLayer()
# feature list
features = list(layer.getFeatures(QgsFeatureRequest().setFlags(QgsFeatureRequest.EmbeddedSymbols)))
# embedded symbols
symbols = [f.embeddedSymbol().clone() if f.embeddedSymbol() else None for f in features]
# colors of embedded symbols
colors = {f.id(): s.color().name() for f, s in zip(features, symbols)}
for color in set(colors.values()):
# features with the same color
feature_ids = [fid for fid, c in colors.items() if c == color]
layer.selectByIds(feature_ids) # select the features
# extract the selected features as temporary layer
output = processing.run("native:saveselectedfeatures",
{'INPUT':layer,
'OUTPUT':'TEMPORARY_OUTPUT'})["OUTPUT"]
# set color and name for the output
output.renderer().symbol().setColor(QColor(color))
output.setName(color)
# add the layer to the project
QgsProject.instance().addMapLayer(output)
