Exporting point file as kml in GRASS GIS

The v.out.ogr function in GRASS GIS let you export your vector layer to any format supported by OGR (it is basically an interface to the GDAL/OGR function ogr2ogr). This includes kml files. E.g.,

v.out.ogr input=labels layer=1 dsn=/home/paulo/test.kml format=KML

will export the vector layer ‘labels’ as the kml file test.kml

When you do this, you may find that the Name and Description fields in the resulting kml file are empty. In that case you probably do not have columns with those names in the attribute table of your vector layer. The v.out.ogr function looks for these columns in your input layer. If doesn’t find it, it leaves the corresponding columns in the kml file empty.

A possible solution would be to rename the two columns you want to use to Name and Description respectively. There is a better solution though. The v.out.ogr function offers an additional parameter, dsco, to define OGR dataset creation options. You can use this to map the columns that should be used for the Name and Description fields.

v.out.ogr input=labels layer=1 dsn=/home/paulo/test.kml format=KML dsco='NameField=PNVname,DescriptionField=PNVcode'

You can also use the GUI (menu: file | export vector map | common export formats). Go to the field ‘OGR dataset options’ under the tab ‘Creation’

GUI for v.out.ogr, with OGR data creation options marked

Of course, this is all described in the help file for v.out.ogr (but I have to admit I overlooked it initially), which is a good starting place if you want more details.

See my next post how to do the same in QGIS. As noted in that post, ogr2ogr, the underlying OGR function used by v.out.ogr, exports the attribute table of the input vector layer as Extended data in the output kml file. In the linked post, I give a method to remove the extended data that v.out.ogr exports


One thought on “Exporting point file as kml in GRASS GIS

  1. Pingback: Exporting vector layer as kml in QGIS | Ecostudies

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s