[GIS] Convert KML to shapefile without losing attribute data

kmlogrpostgispostgresqlshapefile

So I want to convert KML files to SHP shapefiles to load it onto PostGIS. Currently I'm using ogr2ogr to do the conversion for me, but it wipes out all the attribute data. How do i preserve this attribute data in the resulting shapefile? Any better feature out there?

Best Answer

Why don't you directly convert a KML file to PostGIS. You can do this using the following command:

ogr2ogr -overwrite -f "PostgreSQL" PG:"host=myIP user=myUser dbname=myDb password=myPassword" yourfile.kml

This will create a table named layer_0(if not already there) with all your attributes.