0

I am currently using QGIS 2.18. I have some code to export certain shapefile layers to bring into KML. When I bring them into Google Earth, the lines are much thinner than I would prefer them to be, and I go through each layer to change their thickness. If possible, I would like to export the KMLs with a certain thickness to save time. I am using symbologyExport=QgsVectorFileWriter.FeatureSymbology, and this keeps the color of the layer but the thickness is not maintained.

for layer in layers:
name=layer.name()
if "Feeder" in name:
    output_layer = r"(FolderStructureLocation...)" +  name + ".kml"
    QgsVectorFileWriter.writeAsVectorFormat(layer, output_layer, "utf-8", layer.crs(), "KML",symbologyExport=QgsVectorFileWriter.FeatureSymbology)

1 Answer 1

3

If you're using up-to-date GDAL/OGR drivers which uses the LIBKML driver for writing kml, you can use the OGR_STYLE functionality described at How to style KML through LIBKML layer creation options? to control line width, color, and various other styling features.

However, since you say you're using a pretty old version of QGIS (2.18 vs the current LTR of 3.4, never mind newest version 3.10), there's at least a chance your installation may also have old OGR drivers not compiled against LIBKML, which is required for this to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.