1

I've converted a bunch of .shp files to .kml using ogr2ogr and I've noticed that the placemark names in Google Earth are not reflected in the newly made kml files. I have also used ogr2gui and found that the placemark names do appear when made with them. With that said, ogr2ogr seems to be the better tool for automatic batch conversion of the files, and hence my desire to stick with it.

Edit: I have been told by Inventis (developers of Ogr2Gui) that by default the shp's column headers are replace by NameField and Description. Then, the driver fills those two tags with the attributes of the DBF.

In this case, could this be a driver issue? should I be building LIBKML and using that instead of the default KML?

I cannot use the 'NameField=' and "Description=" since the header names vary with each shp file.

Can someone help?

1 Answer 1

2

With the OGR KML driver, you have to explicitly tell it which field is the one you want to map to the Name field:

ogr2ogr -f KML output.kml input.shp -dsco NameField=Site_ID
3
  • Hello again, and thanks for the previous answer. As I am finding out now, the attribute types for the many shp files I am trying to convert does not remain constant. Sometimes there is not even a "SITE_ID". I need to be able to batch convert them all at once. Is there another way to approach this? Maybe somehow tell ogr2ogr to look at the first 2 attributes of a shp file (if there is such a thing)?
    – Drew Win
    Commented Sep 3, 2013 at 22:48
  • Edit: I have been told by Inventis (developers of Ogr2Gui) that by default the shp's column headers are replace by NameField and Description. Then, the driver fills those two tags with the attributes of the DBF. In this case, could this be a driver issue? should I be building LIBKML and using that instead of the default KML?
    – Drew Win
    Commented Sep 11, 2013 at 23:08
  • You're going to have to pick out the right columns manually because your data is not well defined. Databases have no concept of "the first two attributes". You could process the output of ogrinfo and use that to generate keys, but it would be ugly.
    – scruss
    Commented Sep 12, 2013 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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