I have a folder full of KML files and I want to create a .shp, .shx, .prj and .dbf files from these KMLs.
How can I accomplish this?
Below is the code that I am working on:
enter code here
import os , glob , qgis
path = r"\KML DUMP"
Location = r"\shapefile"
files = glob.iglob(os.path.join(path,"*.KML"))
num=1
for file in files:
if os.path.isfile(file):
layer = QgsVectorLayer(path + file, file, "ogr")
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, os.path.join(Location,'shape'+str(num)+'.shp'), "utf-8", layer.crs(), "ESRI Shapefile")
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, os.path.join(Location,'shape'+str(num)+'.shp'), "utf-8", layer.crs(), "ESRI Shx file")
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, os.path.join(Location,'shape'+str(num)+'.shp'), "utf-8", layer.crs(), "ESRI dbf file")
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, os.path.join(Location,'shape'+str(num)+'.shp'), "utf-8", layer.crs(), "ESRI prj file")
num= num+1