0

I have a KML-file (available here). It has several polygon paths for Alos/Palsar images.

I am in need to convert all these files from KML to shapefile, saving the layers using the layer "ID".

I am trying to use the piece of code bellow (PyQGIS), but I do not know how to unzip this KML and save the shapefiles using the layer "ID" information

vlayer = QgsVectorLayer("D:/KML-Images/A_Cycle06.kml", "line", "ogr")

writer = QgsVectorFileWriter.writeAsVectorFormat(vlayer, "D:/KML-Images/<layer ID>.shp", "utf-8", None, "ESRI Shapefile")
  • A_Cycle06.kml isn't a zip file, it looks like a regular KML (XML) file. – nmtoken Mar 18 at 15:52
  • Hi @mmtoken, but even though the tasks bellow are not doing the right convertion vlayer = QgsVectorLayer("D:/KML-Images/A_Cycle06.kml", "polygon", "ogr") writer = QgsVectorFileWriter.writeAsVectorFormat(vlayer, "D:/KML-Images/A_Cycle06.shp", "utf-8", None, "ESRI Shapefile") – HelpOverFlow Mar 18 at 17:13
0

Run QGIS 3.4 and higher,

then Layer> Add layer> Add vector layer choose path> add see figure 1.

enter image description here

Then select files in parts, just don’t choose to select all,

see result figure 2,

enter image description here

they are grouped, then save to *.shp

P.S. I think that the problem of processing the grouped file you provided is *.KML is that each individual file has a field value of ID = 1, which causes the program to "hang", perhaps something else ...

with respect

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.