2

I have one big layer which contains many polygons. This layer is a shapefile and I want to convert it to be many layers, each layer containing one polygon, and those polygon layers should be saved as KML. I have tried to use the tool ''Convert Format'' as I was advised by other people but I can't understand how to make it into KML and all I get is a new layer called ''converted'' and I can't find the difference.

What did I miss? enter image description here

The end goal is to have many KML filles in the end, one KML layer per polygon

  • How does "save as/export" when you rightclick the layer not suit your needs? Beyond that: Please consult the documentation for the tool: docs.qgis.org/2.8/en/docs/user_manual/processing_algs/gdalogr/… – Erik Aug 29 at 10:21
  • Because I have many layers to do it so if I gonna do it one by one it's gonna take me few years – Reut Aug 29 at 10:22
  • 1
    @Reut - Click the ellipses button to the right when saving, you can select the output type. – Joseph Aug 29 at 10:23
  • 1
    @Reut - (comment based on OP's recent edit): Ensure each polygon has a unique attribute (you could use the Field Calculator and set an expression like $rownum). Then use the Split vector layer tool to export each polygon as an individual shapefile. Then use the Convert format in batch mode, set the input and output settings and ensure the output type is KML (note: make use of Autofill property to make your life easy). – Joseph Aug 29 at 11:10
  • @Joseph, what is the Autofill property? – Reut Aug 29 at 12:02
5

As per the comment, you need to choose the format you want to convert to by choosing the Save to file option in the 'Converted section, and then picking the format you want to convert to.

Convert format

You need to end up with a GDAL command that begins with

ogr2ogr -f "LIBKML"

You have to do this because the default option for this tool as per the documentation is save to shapefile

4

How to split a vector layer and convert it to KML format

The split vector layer tool creates geopackage files by default. If this is a process you do frequently, it may be worthwhile to follow the steps here to change the output setting for this tool. Otherwise, it takes two steps to split your layer and convert it to KML.

  1. Split the layer using the split vector layer tool, in the Processing Toolbox. Save the split layers to a new folder, which you will delete after the next step. Don't import the split layers into your project.

  2. Run the GDAL Convert format tool in batch processing mode.

    enter image description here

    Click the ellipsis button (...) and choose the option to "Select from file system."

    enter image description here

    Open the folder you created in step 1. Select all the split files in the folder. They will load into the batch processing window.

Once step 2 is complete, delete the folder you created in step 1.

  • Best answer, using nothing but built-in tools. – Gabriel C. Aug 29 at 16:33
3

You can create separate polygons in KML format directly when using the Convert format tool without using other tools as follows and using an example:

  • This is a grid shapefile with 20 polygons

enter image description here

  • Use Convert format tool from Processing toolbox -> GDAL -> Vector Conversion -> Convert format
  • Select Input Polygon shapefile (20 polygons above in this example)
  • Select iterator (green arrow) beside the input Layer
  • Under Converted, click on the three dots ... to give a name to the output KML file (Polygon in this example) and select KML format, then save. See the image below.

enter image description here

  • Run the tool. Here is the output

enter image description here

  • Each file of them is composed of one polygon in KML format:

enter image description here

2

Here is a solution that I think will work for you:

  1. Go to Plugins and install the mmqgis-plugin

Mmqgis plugin

  1. Use the plugins' combine function to merge your layers.

  2. Save/export the combined layer as KML.

  • 1
    this is good but the problem is that at the beggining I have very big layer with many plots and I want to get in the end all those plots, seperated, each one saved as KML. i'll also edit my question for it to be clear – Reut Aug 29 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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