## Expand description

The `geo`

crate provides geospatial primitive types and algorithms.

## §Types

: A two-dimensional coordinate. All geometry types are composed of`Coord`

`Coord`

s, though`Coord`

itself is not a`Geometry`

type.: A single point represented by one`Point`

`Coord`

: A collection of`MultiPoint`

`Point`

s: A line segment represented by two`Line`

`Coord`

s: A series of contiguous line segments represented by two or more`LineString`

`Coord`

s: A collection of`MultiLineString`

`LineString`

s: A bounded area represented by one`Polygon`

`LineString`

exterior ring, and zero or more`LineString`

interior rings: A collection of`MultiPolygon`

`Polygon`

s: An axis-aligned bounded rectangle represented by minimum and maximum`Rect`

`Coord`

s: A bounded area represented by three`Triangle`

`Coord`

vertices: A collection of`GeometryCollection`

`Geometry`

s: An enumeration of all geometry types, excluding`Geometry`

`Coord`

The preceding types are reexported from the `geo-types`

crate. Consider using that crate
if you only need access to these types and no other `geo`

functionality.

### §Semantics

The geospatial types provided here aim to adhere to the OpenGIS Simple feature access standards. Thus, the types here are inter-operable with other implementations of the standards: JTS, GEOS, etc.

## §Algorithms

### §Area

: Calculate the planar area of a geometry`Area`

: Calculate the geodesic area of a geometry on a sphere using the algorithm presented in`ChamberlainDuquetteArea`

*Some Algorithms for Polygons on a Sphere*by Chamberlain and Duquette (2007): Calculate the geodesic area and perimeter of a geometry on an ellipsoid using the algorithm presented in`GeodesicArea`

*Algorithms for geodesics*by Charles Karney (2013)

### §Boolean Operations

: combine or split (Multi)Polygons using intersecton, union, xor, or difference operations`BooleanOps`

### §Distance

: Calculate the minimum euclidean distance between geometries`EuclideanDistance`

: Calculate the minimum geodesic distance between geometries using the algorithm presented in`GeodesicDistance`

*Algorithms for geodesics*by Charles Karney (2013): Calculate “the maximum of the distances from a point in any of the sets to the nearest point in the other set.” (Rote, 1991)`HausdorffDistance`

: Calculate the minimum geodesic distance between geometries using the haversine formula`HaversineDistance`

: Calculate the length of a rhumb line connecting the two geometries`RhumbDistance`

: Calculate the minimum geodesic distance between geometries using Vincenty’s formula`VincentyDistance`

### §Length

: Calculate the euclidean length of a geometry`EuclideanLength`

: Calculate the geodesic length of a geometry using the algorithm presented in`GeodesicLength`

*Algorithms for geodesics*by Charles Karney (2013): Calculate the geodesic length of a geometry using the haversine formula`HaversineLength`

: Calculate the length of a geometry assuming it’s composed of rhumb lines`RhumbLength`

: Calculate the geodesic length of a geometry using Vincenty’s formula`VincentyLength`

### §Outlier Detection

: Detect outliers in a group of points using LOF`OutlierDetection`

### §Simplification

: Simplify a geometry using the Ramer–Douglas–Peucker algorithm`Simplify`

: Calculate a simplified geometry using the Ramer–Douglas–Peucker algorithm, returning coordinate indices`SimplifyIdx`

: Simplify a geometry using the Visvalingam-Whyatt algorithm`SimplifyVw`

: Simplify a geometry using a topology-preserving variant of the Visvalingam-Whyatt algorithm`SimplifyVwPreserve`

: Calculate a simplified geometry using the Visvalingam-Whyatt algorithm, returning coordinate indices`SimplifyVwIdx`

### §Query

: Calculate the bearing between points using great circle calculations.`HaversineBearing`

: Calculate the bearing between points on a geodesic`GeodesicBearing`

: Calculate the angle from north of the rhumb line connecting two points.`RhumbBearing`

: Find the point on a geometry closest to a given point`ClosestPoint`

: Find the point on a geometry closest to a given point on a sphere using spherical coordinates and lines being great arcs.`HaversineClosestPoint`

: Calculate the convexity of a`IsConvex`

`LineString`

: Generates a point that lies a given fraction along the line`LineInterpolatePoint`

: Calculate the fraction of a line’s total length representing the location of the closest point on the line to the given point`LineLocatePoint`

### §Similarity

: Calculate the similarity between`FrechetDistance`

`LineString`

s using the Fréchet distance

### §Topology

: Calculate if a geometry contains another geometry`Contains`

: Calculate the position of a coordinate relative to a geometry`CoordinatePosition`

: Determine the dimensions of a geometry`HasDimensions`

: Calculate if a geometry intersects another geometry`Intersects`

: Calculates the intersection, if any, between two lines.`line_intersection`

: Topologically relate two geometries based on DE-9IM semantics.`Relate`

: Calculate if a geometry lies completely within another geometry.`Within`

### §Triangulation

: Triangulate polygons using the earcut algorithm (requires the`TriangulateEarcut`

`earcutr`

feature).

### §Winding

: Apply a specified winding`Orient`

`Direction`

to a`Polygon`

’s interior and exterior rings: Calculate and manipulate the`Winding`

`WindingOrder`

of a`LineString`

### §Iteration

: Iterate over the coordinates of a geometry`CoordsIter`

: Map a function over all the coordinates in a geometry, returning a new geometry`MapCoords`

: Map a function over all the coordinates in a geometry in-place`MapCoordsInPlace`

: Iterate over lines of a geometry`LinesIter`

### §Boundary

: Calculate the axis-aligned bounding rectangle of a geometry`BoundingRect`

: Calculate the minimum bounding box of a geometry`MinimumRotatedRect`

: Calculate the concave hull of a geometry`ConcaveHull`

: Calculate the convex hull of a geometry`ConvexHull`

: Calculate the extreme coordinates and indices of a geometry`Extremes`

### §Affine transformations

: Rotate a geometry around its centroid`Rotate`

: Scale a geometry up or down by a factor`Scale`

: Skew a geometry by shearing angles along the`Skew`

`x`

and`y`

dimension: Translate a geometry along its axis`Translate`

: generalised composable affine operations`AffineOps`

### §Conversion

: Convert (infalliby) the type of a geometry’s coordinate value`Convert`

: Convert (falliby) the type of a geometry’s coordinate value`TryConvert`

: Radians to degrees coordinate transforms for a given geometry.`ToDegrees`

: Degrees to radians coordinate transforms for a given geometry.`ToRadians`

### §Miscellaneous

: Calculate the centroid of a geometry`Centroid`

: Smoothen`ChaikinSmoothing`

`LineString`

,`Polygon`

,`MultiLineString`

and`MultiPolygon`

using Chaikin’s algorithm.: Densify linear geometry components by interpolating points`Densify`

: Densify spherical geometry by interpolating points on a sphere`DensifyHaversine`

: Given a start point, bearing, and distance, calculate the destination point on a geodesic`GeodesicDestination`

: Calculate intermediate points on a geodesic`GeodesicIntermediate`

: Given a start point, bearing, and distance, calculate the destination point on a sphere assuming travel on a great circle`HaversineDestination`

: Calculate intermediate points on a sphere along a great-circle line`HaversineIntermediate`

: Given a start point, bearing, and distance, calculate the destination point on a sphere assuming travel along a rhumb line`RhumbDestination`

: Calculate intermediate points on a sphere along a rhumb line`RhumbIntermediate`

**[**: Project geometries with the`proj`

]`proj`

crate (requires the`use-proj`

feature): Segment a LineString into`LineStringSegmentize`

`n`

segments.: Segment a LineString using Haversine distance.`LineStringSegmentizeHaversine`

**[**: Transform a geometry using Proj.`Transform`

]: Remove repeated points from a geometry.`RemoveRepeatedPoints`

## §Features

The following optional Cargo features are available:

`proj-network`

: Enables network grid support for the`proj`

crate. After enabling this feature, further configuration is required to use the network grid`use-proj`

: Enables coordinate conversion and transformation of`Point`

geometries using the`proj`

crate`use-serde`

: Allows geometry types to be serialized and deserialized with Serde

## §Ecosystem

There’s a wide variety of `geo`

-compatible crates in the ecosystem that offer functionality not
included in the `geo`

crate, including:

- Reading and writing file formats (e.g. GeoJSON, WKT, shapefile)
- Latitude and longitude parsing
- Label placement
- Geocoding
- and much more…

## Re-exports§

## Modules§

- This module includes all the functions of geometric calculations
- This module makes all geometry types available
- A prelude which re-exports the traits for manipulating objects in this crate. Typically imported with
`use geo::prelude::*`

.

## Macros§

- Creates a
`Coord`

from the given scalars. - Implements the common pattern where a Geometry enum simply delegates its trait impl to it’s inner type.
- Creates a
`LineString`

containing the given coordinates. - Creates a
`Point`

from the given coordinates. - Creates a
`Polygon`

containing the given coordinates. - Creates a
`crate::geometry`

from a WKT literal.

## Enums§

- The result of trying to find the closest spot on an object to a point.

## Traits§

- For algorithms which can only use floating point
`Point`

s/`Coord`

s, like area or length calculations - For algorithms which can use both integer
**and**floating point`Point`

s/`Coord`

s - A common numeric trait used for geo algorithms
- A trait for methods which work for both integers
**and**floating point