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 please help?

Cheers!

1

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
  • 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 Sep 3 '13 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 Sep 11 '13 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 Sep 12 '13 at 1:23

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.