Markdown Editor

Reference Documentation Template (Diataxis)

Diátaxis reference page – neutral, consistently structured entries for functions, types, errors and constants

Dokumentasi & DukunganStandarDiátaxisCC BY-SA 4.0referencemath

Cara menggunakan: Use to describe machinery that readers consult while working. Fix the entry format first and apply it to every item, mirroring the product's structure. The main pitfall is slipping instructions or rationale into reference entries.

Pratinjau

[Component name] Reference

Reference page in the Diátaxis sense: a neutral, complete, consistently structured description of the machinery (functions, fields, endpoints, commands or parts) that a user consults while working. Adapted from the Diátaxis framework by Daniele Procida (CC BY-SA 4.0). Replace every [bracketed] value and every entry marked Example.

FieldValue
Describes[Component or library name] [version 3.1]
Audience[Developers using the library / Operators / End users]
Owner[@maintainer]
Generated from[Source docstrings / OpenAPI / Hand-written]
Last updatedYYYY-MM-DD

Overview

This page describes the public interface of [geo-utils] [3.1]: its modules, functions, data types, constants and errors. Entries are grouped by module and listed alphabetically within each group. Items not listed here are internal and may change without notice.

ModuleContents
geo.distanceFunctions that measure distance between coordinates
geo.typesData types used across the package
geo.errorsExceptions raised by the package

Entry format

Each entry contains, in this order:

PartContent
SignatureExact name and parameters as they appear in code
SummaryOne sentence describing what the item is or returns
ParametersTable: name, type, required, default, description
ReturnsType and meaning of the result
RaisesErrors and the conditions that cause them
ConstraintsLimits, units, thread safety, complexity
ExampleA minimal illustration of input and output
SinceVersion that introduced the item; changes in later versions

Conventions

ConventionMeaning
* in a signatureParameters after it must be passed by keyword
Required: YesThe call fails if the parameter is missing
Default: noneThe parameter has no default value
UnitsDistances in kilometres and angles in decimal degrees unless the entry states otherwise
Thread safeThe item can be used from several threads at once without locking
O(⋅)O(\cdot)Time complexity in the number of input points
SinceFirst version in which the item is public; later changes are listed after it

All functions accept and return values by value; none modifies its arguments. Floating-point results follow IEEE 754 double precision and are not rounded unless the entry states a precision.

Module geo.distance

haversine(a, b, *, unit="km")

Example entry. Returns the great-circle distance between two points on a sphere with the mean Earth radius.

ParameterTypeRequiredDefaultDescription
aPointYesnoneFirst point
bPointYesnoneSecond point
unitstrNo"km"One of "km", "m", "mi", "nmi"

Returns: float, the distance in the requested unit, always ≥0\ge 0.

Raises: InvalidUnitError if unit is not one of the listed values.

Constraints: Uses radius R=6371.0088R = 6371.0088 km. Error versus the WGS 84 ellipsoid is up to about 0.5%. Pure function; thread safe; O(1)O(1).

The distance computed is

d=2Rarcsin⁡(sin⁡2Δφ2+cos⁡φ1cos⁡φ2sin⁡2Δλ2)d = 2R \arcsin\left(\sqrt{\sin^2\frac{\Delta\varphi}{2} + \cos\varphi_1 \cos\varphi_2 \sin^2\frac{\Delta\lambda}{2}}\right)

Example:

>>> haversine(Point(52.52, 13.405), Point(48.857, 2.352))
877.46

Since: 1.0. unit="nmi" added in 2.4.

vincenty(a, b, *, unit="km", max_iter=200)

Example entry. Returns the geodesic distance between two points on the WGS 84 ellipsoid.

ParameterTypeRequiredDefaultDescription
aPointYesnoneFirst point
bPointYesnoneSecond point
unitstrNo"km"One of "km", "m", "mi", "nmi"
max_iterintNo200Iteration limit, 1 to 1000

Returns: float, the distance in the requested unit.

Raises: InvalidUnitError for an unknown unit; ConvergenceError when the iteration does not converge within max_iter, which can happen for nearly antipodal points.

Constraints: Accuracy within 0.5 mm when converged. Thread safe.

Example:

>>> vincenty(Point(52.52, 13.405), Point(48.857, 2.352), unit="m")
879697.6

Since: 2.0.

Module geo.types

Point(lat, lon)

Example entry. An immutable geographic coordinate in decimal degrees.

FieldTypeConstraintsDescription
latfloat−90≤lat≤90-90 \le lat \le 90Latitude, positive north
lonfloat−180≤lon≤180-180 \le lon \le 180Longitude, positive east

Raises: CoordinateRangeError on construction if a field is out of range.

Constraints: Hashable; equality compares both fields exactly.

Since: 1.0.

[TypeName]

[One-sentence summary.]

FieldTypeConstraintsDescription
[field][type][constraint][description]

Since: [x.y].

Module geo.errors

ErrorBase classRaised whenSince
GeoErrorExceptionBase class for all package errors1.0
CoordinateRangeErrorGeoError, ValueErrorA latitude or longitude is out of range1.0
InvalidUnitErrorGeoError, ValueErrorA unit name is not recognised1.0
ConvergenceErrorGeoErrorAn iterative method exceeds its iteration limit2.0

Constants

NameTypeValueMeaning
EARTH_RADIUS_KMfloat6371.0088Mean Earth radius
WGS84_Afloat6378137.0Semi-major axis in metres
WGS84_Ffloat1 / 298.257223563Flattening

Version history

VersionChange
3.1Example: max_iter upper bound raised from 500 to 1000
2.4Example: Added unit "nmi"
2.0Example: Added vincenty and ConvergenceError

Related documentation

  • Tutorial: [Your first distance calculation]
  • How-to guide: [How to choose a distance method for your accuracy needs]
  • Explanation: [Why the Earth is not a sphere: geodesy basics]

Standard and licence note

The structure of this template is adapted from the Diátaxis framework by Daniele Procida (https://diataxis.fr), licensed under CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/). The template text is original; the adapted structure is shared under CC BY-SA 4.0.

Templat terkait