An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

# go-kml

[![PkgGoDev](https://pkg.go.dev/badge/github.com/twpayne/go-kml/v3)](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