[GIS] KML to shapefile (ogr2ogr)

gdalkmlogrshapefile

I am trying to convert KML to shapefile.

I'm using ogr2ogr (gdal version = 2.0.0).
Here is the command:

/home/vineet/Project/gdal-2.0.0/bin/ogr2ogr --config  SHAPE_ENCODING UTF-8 -update -append  output.shp /home/vineet/Desktop/rail.kml -nln output -nlt GEOMETRY

I have all three ways mentioned here: ogr2ogr kml to shp conversion created 184 shapefiles?! What am I missing?

And each time its giving me same error:

Warning 6: Normalized/laundered field name: 'description' to 'descriptio'

Warning 6: Field timestamp create as date field, though DateTime requested.
Warning 6: Field begin create as date field, though DateTime requested.

Warning 6: Field end create as date field, though DateTime requested.

Warning 6: Normalized/laundered field name: 'altitudeMode' to 'altitudeMo'

FAILED: Layer output already exists, and -append not specified.
Consider using -append, or -overwrite.

ERROR 1: Terminating translation prematurely after failed
translation of layer Professional Leagues (use -skipfailures to skip errors)

Any idea why ogr is giving me these errors?

OR

Any other way to directly dump KML to PostGIS (all data in single table)

Best Answer

It's actually much simpler than what you've got going on there.

ogr2ogr outputShapefile.shp input.kml

Of course you can also use other option to specify srs etc. for example I work alot with a non standard crs, Lowrance Mercator Meter, so I use:

ogr2ogr -t_srs "+proj=merc +a=6356752.3142 +b=6356752.3142 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs" outputShapefile.shp input.kml

to have the shapefile built with the proper crs.