kmlio

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package kmlio reads and writes KML (Keyhole Markup Language, OGC 12-007r2) as gobi Frames.

KML always stores coordinates in WGS 84 (lon, lat[, alt]) per the OGC spec, so output frames have their geometry column tagged with EPSG:4326.

The reader flattens every <Placemark> in the document. Each placemark contributes one row with columns:

  • name (string, from <name>)
  • description (string, from <description>)
  • geometry (WKB Binary, tagged EPSG:4326)
  • <ext-key> one string column per distinct <ExtendedData><Data> name= attribute seen in the document

The writer emits one <Placemark> per row. String / numeric columns other than "name", "description", and the geometry column become <ExtendedData> entries.

Not implemented (out of scope for a small first cut):

  • <Style>, <StyleMap>, <NetworkLink>, <Document> nesting semantics
  • Time / TimeSpan primitives
  • KMZ (zipped KML) — deliberately deferred; use gzip/zstd via csvio as a stopgap or unzip first
  • Non-primitive KML geometries (Model, gx:Track)

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKML = errors.New("kmlio: invalid input")

ErrInvalidKML is returned when the input isn't a well-formed KML or uses a construct this package doesn't support.

Functions

func Read

func Read(r io.Reader, opts *ReadOptions) (*gobi.Frame, error)

Read parses a KML document from r into a Frame. Pass nil opts for defaults.

func ReadFile

func ReadFile(path string, opts *ReadOptions) (*gobi.Frame, error)

ReadFile parses path and returns a Frame. See package doc for the column shape. Pass nil opts for defaults.

func Write

func Write(f *gobi.Frame, w io.Writer, opts *WriteOptions) error

Write encodes f to w as a KML document (namespace 2.2). Pass nil opts for defaults.

func WriteFile

func WriteFile(f *gobi.Frame, path string, opts *WriteOptions) error

WriteFile writes f to path as KML. See package doc for the column conventions the writer looks for. Pass nil opts for defaults.

Types

type ReadOptions

type ReadOptions struct{}

ReadOptions reserves a slot for future read-time configuration (e.g., skip-Style, geometry-column-name override, folder-name prefixing). Currently empty — pass nil.

The struct exists so future options can be added without breaking the ReadFile / Read signatures. Matches the naming pattern used by parquetio, csvio, gpkgio, geojsonio, and pgio.

type WriteOptions

type WriteOptions struct{}

WriteOptions reserves a slot for future write-time configuration (e.g., document-name / description, KMZ compression, style injection). Currently empty — pass nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL