https://github.com/twpayne/go-kml
Package kml provides convenience methods for creating and writing KML documents.
https://github.com/twpayne/go-kml
encoding geospatial gis go golang google-earth kml
Last synced: about 1 month ago
JSON representation
Package kml provides convenience methods for creating and writing KML documents.
- Host: GitHub
- URL: https://github.com/twpayne/go-kml
- Owner: twpayne
- License: mit
- Created: 2015-11-17T23:23:29.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-04-03T21:07:10.000Z (3 months ago)
- Last Synced: 2025-05-14T03:09:12.985Z (about 1 month ago)
- Topics: encoding, geospatial, gis, go, golang, google-earth, kml
- Language: Go
- Homepage:
- Size: 199 KB
- Stars: 92
- Watchers: 4
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-kml
[](https://pkg.go.dev/github.com/twpayne/go-kml/v3)
Package `kml` provides convenience methods for creating and writing KML documents.
## Key Features
* Simple API for building arbitrarily complex KML documents.
* Support for all KML elements, including Google Earth `gx:` extensions.
* Compatibility with the standard library [`encoding/xml`](https://pkg.go.dev/encoding/xml) package.
* Pretty (neatly indented) and compact (minimum size) output formats.
* Support for shared `Style` and `StyleMap` elements.
* Simple mapping between functions and KML elements.
* Convenience functions for using standard KML icons.
* Convenience functions for spherical geometry.## Example
```go
func ExampleKML() {
k := kml.KML(
kml.Placemark(
kml.Name("Simple placemark"),
kml.Description("Attached to the ground. Intelligently places itself at the height of the underlying terrain."),
kml.Point(
kml.Coordinates(kml.Coordinate{Lon: -122.0822035425683, Lat: 37.42228990140251}),
),
),
)
if err := k.WriteIndent(os.Stdout, "", " "); err != nil {
log.Fatal(err)
}
}
```Output:
```xml
Simple placemark
Attached to the ground. Intelligently places itself at the height of the underlying terrain.
-122.0822035425683,37.42228990140251
```
There are more [examples in the
documentation](https://pkg.go.dev/github.com/twpayne/go-kml/v3#pkg-examples)
corresponding to the [examples in the KML
tutorial](https://developers.google.com/kml/documentation/kml_tut).## Subpackages
* [`icon`](https://pkg.go.dev/github.com/twpayne/go-kml/v3/icon) Convenience functions for using standard KML icons.
* [`sphere`](https://pkg.go.dev/github.com/twpayne/go-kml/v3/sphere) Convenience functions for spherical geometry.## License
MIT