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

ahmadhanb
  • 40,826
  • 5
  • 51
  • 105
ReutKeller
  • 2,139
  • 4
  • 30
  • 84
  • How does "save as/export" when you rightclick the layer not suit your needs? Beyond that: Please consult the documentation for the tool: https://docs.qgis.org/2.8/en/docs/user_manual/processing_algs/gdalogr/ogr_conversion/convertformat.html – Erik Aug 29 '19 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 – ReutKeller Aug 29 '19 at 10:22
  • 1
    @Reut - Click the ellipses button to the right when saving, you can select the output type. – Joseph Aug 29 '19 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 '19 at 11:10
  • @Joseph, what is the Autofill property? – ReutKeller Aug 29 '19 at 12:02
  • @Reut - If you run the tool as a batch process (right-clicking it from the Processing Toolbox), you can have it set the input and output paths automatically. – Joseph Aug 29 '19 at 12:04
  • when I used the split vector layers, each layer got name. is there any way to keep those names when I save it as kml? – ReutKeller Aug 29 '19 at 13:16

4 Answers4

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

nmtoken
  • 13,355
  • 5
  • 38
  • 87
5

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.

csk
  • 24,827
  • 3
  • 32
  • 70
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

ahmadhanb
  • 40,826
  • 5
  • 51
  • 105
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 – ReutKeller Aug 29 '19 at 11:01