0

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)

  • Part of your problem might be that you are listing append to the output.shp, but then you are also listing a new layer name with the same output name. You may need to choose one or the other, but not both. – Get Spatial May 27 '16 at 10:36
  • The warnings are just that. Only the Error is an error. – Vince May 27 '16 at 11:04
  • -nln is at least not necessary with shapefiles because they can have only one layer and the name of the layer is the same as the base of the filename. – user30184 May 27 '16 at 13:27
  • Warning come from the limitation of the shape format, maximum length of column names in a DBF file is 10 characters – Zoltan Jun 2 '16 at 4:34
2

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.

  • Yes I'm using ogr2ogr in this way, but i want to dump this kml into postgres so what i did : ogr2ogr --config SHAPE_ENCODING UTF-8 -f "ESRI Shapefile" outputshapefile.shp input.kml and than I'm using shp2pgsql with pgsql command to insert data in postgres. Thanks for the srs part. – vinni Jun 6 '16 at 13:57
0

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

You can do this by adding -nln tablename like this -

ogr2ogr -f PostgreSQL PG:"dbname='db' host='host' port='port' user='user' password='password'" input.kml -nln tablename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.