package
0.5.0
Repository: https://github.com/qri-io/starlib.git
Documentation: pkg.go.dev

# README

geo

geo defines geographic operations in two-dimensional space

Functions

Line(points) Line

Line constructor. Takes either an array of coordinate pairs or an array of point objects and returns the line that connects them. Points do not need to be collinear, providing a single point returns a line with a length of 0

parameters:

nametypedescription
points`[[]floatPoint]`

MultiPolygon(polygons) MultiPolygon

MultiPolygon constructor. MultiPolygon groups a list of polygons to behave like a single polygon

parameters:

nametypedescription
polygons[Polygon]

Point(x,y) Point

Point constructor, takes an x(longitude) and y(latitude) value and returns a Point object

parameters:

nametypedescription
xfloatx-dimension value (longitude if using geodesic space)
yfloaty-dimension value (latitude if using geodesic space)

Polygon(rings) Polygon

Polygon constructor. Takes a list of lists of coordinate pairs (or point objects) that define the outer boundary and any holes / inner boundaries that represent a polygon. In GIS tradition, lists of coordinates that wind clockwise are filled regions and anti-clockwise represent holes.

parameters:

nametypedescription
rings[Line]list of closed lines that constitute the polygon

parseGeoJSON(data) (geoms, properties)

Parses string data in IETF-7946 format (https://tools.ietf.org/html/rfc7946) returning a list of geometries and equal-length list of properties for each geometry

parameters:

nametypedescription
datastringstring of GeoJSON data

within(geom,polygon) bool

Returns True if geom is entirely contained by polygon

parameters:

nametypedescription
geom[point,line,polygon]maybe-inner geometry
polygon[Polygon,MultiPolygon]maybe-outer polygon

Types

Line

an ordered list of points that define a line Methods

length() float

Euclidean Length

geodesicLength() float

Line length on the surface of a sphere with the same radius as Earth

MultiPolygon

MultiPolygon groups a list of polygons to behave like a single polygon### Point a two-dimensional point in space Methods

distance(p2) float

Euclidean Distance to the other point

parameters:

nametypedescription
p2``point to measure distance to

distanceGeodesic(p2) float

Distance on the surface of a sphere with the same radius as Earth

parameters:

nametypedescription
p2pointpoint to measure distance to

Polygon

an ordered list of closed lines (rings) that define a shape. lists of coordinates that wind clockwise are filled regions and anti-clockwise represent holes.