Documentation ¶
Overview ¶
Package proj transforms coordinates with Proj.
// New Proj by EPSG code. wgs84, err := proj.NewEPSG(4326) if err != nil { log.Fatal(err) } // Proj by definition string. utm32, err := proj.New("epsg:25832") if err != nil { log.Fatal(err) } pts := []proj.Coord{ proj.XY(53.2, 8.15), proj.XY(52.32, 9.12), } // Transform all coordinates to UTM 32 (in-place). if err := wgs84.Transform(utm32, pts); err != nil { log.Fatal(err) } // All coordinates are expected to be in EPSG axis order. // Call NormalizeForVisualization if your coordinates are always in lon/lat, E/N order. wgs84.NormalizeForVisualization() if err := wgs84.Transform(utm32, []proj.Coord{proj.XY(8.15, 53.2)}); err != nil { log.Fatal(err) } // Transformer from src to dst projection. transf, err := proj.NewTransformer("epsg:25832", "epsg:3857") if err != nil { log.Fatal(err) } if err := transf.Transform(pts); err != nil { log.Fatal(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Proj ¶
type Proj struct {
// contains filtered or unexported fields
}
Proj represents a single coordinate reference system.
func New ¶
New initializes new projection with a proj init string (e.g. "epsg:4326", or "+proj=longlat +datum=WGS84 +no_defs").
func (*Proj) Description ¶
Definition returns projection description.
func (*Proj) Free ¶
func (p *Proj) Free()
Free deallocates the projection immediately. Proj will be deallocated on garbage collection otherwise.
func (*Proj) IsLatLong ¶
IsLatLong returns whether the projection uses lat/long coordinates, instead projected.
func (*Proj) NormalizeForVisualization ¶
NormalizeForVisualization converts axis order so that coordinates are always x/y or long/lat axis order. The EPSG axis order is ignored when calling Transform.
type Transformer ¶
Transformer projects coordinates from Src to Dst.
func NewEPSGTransformer ¶
func NewEPSGTransformer(srcEPSG, dstEPSG int) (Transformer, error)
NewEPSGTransformer initializes a new transformer with src and dst projection by the numeric EPSG code.
func NewTransformer ¶
func NewTransformer(initSrc, initDst string) (Transformer, error)
NewTransformer initializes new transformer with src and dst projection with a full proj4 init string (e.g. "+proj=longlat +datum=WGS84 +no_defs").
func (*Transformer) NormalizeForVisualization ¶
func (t *Transformer) NormalizeForVisualization() error
func (*Transformer) Transform ¶
func (t *Transformer) Transform(pts []Coord) error
Transform coordinates fron src to dst projection. Transforms coordinates in-place.