I have the requirement to convert a list of ~100 KML files into shapefiles and later merge and upload the polygons as one layer into ArcGIS. I'm new to GIS and Python.
I've been able to convert multiple KML files in a directory into ESRI Shapefiles (.shp, .shx, .prj, .dbf) within the same directory by installing ogr2ogr in Conda and running this in Command Line:
<strike>for %f in (*.kml) do ogr2ogr -f "ESRI shapefile" "%f"</strike>
EDIT (correct code):
for %f in (*.kml) do ogr2ogr -f "ESRI Shapefile" "%~nf.shp" "%f"
This results in the following:
How can I add onto this to move the output files to a separate folder similar to this: C:\\Users\\Desktop\\DAT Files\\Redshift Data Testing\\Output
as well as zip each group of .shp, .shx, .prj, .dbf by location (Cherry Hill, State College, etc.) similar to this:
As a follow-up question, would it be possible to create a Python program to call and perform these actions?
I will table the requirements to merge these outputs and upload into ArcGIS for now as just getting the above down would be a HUGE win for me! (I also can perform that manually for now)
The post that I used for reference was: Using ogr2ogr to convert all shapefiles in directory?
for %f in (*.kml) do ogr2ogr -f "ESRI shapefile" "%f"
this code does not give shapefiles.for %f in (*.kml) do ogr2ogr -f "ESRI shapefile" "%f.shp" %f
this worked