I am looking for a way to convert KML to three Shapefiles (point, line, polygon) with a Windows script (exe or bat). The script should open a window to choose the input KML and save the three Shapefiles to a defined path with a defined coordinate reference system.
closed as off-topic by ahmadhanb, tinlyx, user30184, Ian Turton♦ Apr 24 '18 at 9:55
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – ahmadhanb, tinlyx, user30184, Ian Turton
You can execute ogr2ogr 3 times with -where statement:
ogr2ogr -where "OGR_GEOMETRY='Point'" ... ogr2ogr -where "OGR_GEOMETRY='LineString'" ... ogr2ogr -where "OGR_GEOMETRY='Polygon'" ...
See OGR SQL page
The bat file (i.e.
export.bat) may looks like:
@echo off ogr2ogr -where "OGR_GEOMETRY='Point'" -f "ESRI Shapefile" points.shp %1 ogr2ogr -where "OGR_GEOMETRY='LineString'" -f "ESRI Shapefile" lines.shp %1 ogr2ogr -where "OGR_GEOMETRY='Polygon'" -f "ESRI Shapefile" polygons.shp %1
And execute string will be:
Optional syntax for working with input parameters can be found here: https://stackoverflow.com/a/3433012/2901140
The ogr2ogr command line may be more complicated to suits your needs.