help writekml                                                                  


writekml -- Keyhole Markup Language file writer


writekml, filename(string) plcategory(varname string) [plname(varname string) pldesc(varname string)]


writekml takes latitude and longitude information from a data set in memory and writes a KML file in the current working directory.


filename(string) is the name of the KML file to be written. If it already exists, it will be replaced.

plcategory(varname string) is the name of the variable that groups the places being mapped. Each group is mapped with paddles (flags) of the same color. The Google Maps API makes available eight colors. Trying to map more groups will return an error message.

plname(varname string) is the name of the variable that stores the names of the places being mapped. These names will show up in bold black letters on the list next to the Google map that the KML file renders.

pldesc(varname string) is the name of the variable that stores descriptions of the places being mapped. The descriptions will show up in smaller, lighter-colored type below the place names in the list.


writekml expects latitude and longitude to be present in the data set as numeric variables with the same names. If place names or descriptions are missing writekml will fill in the category name instead. The easiest way to associate latitude and longitude information with a data set of physical addresses is to run geocode (if installed) before running writekml.


. writekml, filename(kmlout) plname(name) pldesc(description) plcategory(kind)


Adam Ozimek and Daniel Miles, the authors of geocode, inspired this.


Gabi Huiber Durham, NC USA

Also see

The article that introduced geocode: Stata Journal, volume 11, number 1: dm0053 The KML documentation