Crate geo[−][src]
The geo
crate provides geospatial primitive types and algorithms.
Types
Coordinate
: A twodimensional coordinate. All geometry types are composed ofCoordinate
s, thoughCoordinate
itself is not aGeometry
type.Point
: A single point represented by oneCoordinate
MultiPoint
: A collection ofPoint
sLine
: A line segment represented by twoCoordinate
sLineString
: A series of contiguous line segments represented by two or moreCoordinate
sMultiLineString
: A collection ofLineString
sPolygon
: A bounded area represented by oneLineString
exterior ring, and zero or moreLineString
interior ringsMultiPolygon
: A collection ofPolygon
sRect
: An axisaligned bounded rectangle represented by minimum and maximumCoordinate
sTriangle
: A bounded area represented by threeCoordinate
verticesGeometryCollection
: A collection ofGeometry
sGeometry
: An enumeration of all geometry types, excludingCoordinate
The preceding types are reexported from the geotypes
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 interoperable with other implementations of the standards: JTS, GEOS, etc.
Algorithms
Area
Area
: Calculate the planar area of a geometryChamberlainDuquetteArea
: Calculate the geodesic area of a geometry
Distance
EuclideanDistance
: Calculate the minimum euclidean distance between geometriesGeodesicDistance
: Calculate the minimum geodesic distance between geometries using the algorithm presented in Algorithms for geodesics by Charles Karney (2013)HaversineDistance
: Calculate the minimum geodesic distance between geometries using the haversine formulaVincentyDistance
: Calculate the minimum geodesic distance between geometries using Vincenty’s formula
Length
EuclideanLength
: Calculate the euclidean length of a geometryGeodesicLength
: Calculate the geodesic length of a geometry using the algorithm presented in Algorithms for geodesics by Charles Karney (2013)HaversineLength
: Calculate the geodesic length of a geometry using the haversine formulaVincentyLength
: Calculate the geodesic length of a geometry using Vincenty’s formula
Simplification
Simplify
: Simplify a geometry using the Ramer–Douglas–Peucker algorithmSimplifyIdx
: Calculate a simplified geometry using the Ramer–Douglas–Peucker algorithm, returning coordinate indicesSimplifyVW
: Simplify a geometry using the VisvalingamWhyatt algorithmSimplifyVWPreserve
: Simplify a geometry using a topologypreserving variant of the VisvalingamWhyatt algorithmSimplifyVwIdx
: Calculate a simplified geometry using a topologypreserving variant of the VisvalingamWhyatt algorithm, returning coordinate indices
Query
Bearing
: Calculate the bearing between pointsClosestPoint
: Find the point on a geometry closest to a given pointIsConvex
: Calculate the convexity of aLineString
LineInterpolatePoint
: Generates a point that lies a given fraction along the lineLineLocatePoint
: Calculate the fraction of a line’s total length representing the location of the closest point on the line to the given point
Similarity
FrechetDistance
: Calculate the similarity betweenLineString
s using the Fréchet distance
Topology
Contains
: Calculate if a geometry contains another geometryCoordinatePosition
: Calculate the position of a coordinate relative to a geometryHasDimensions
: Determine the dimensions of a geometryIntersects
: Calculate if a geometry intersects another geometryline_intersection
: Calculates the intersection, if any, between two lines.Relate
: Topologically relate two geometries based on DE9IM semantics.
Winding
Orient
: Apply a specifiedWinding
to aPolygon
’s interior and exterior ringsWinding
: Calculate and manipulate the winding order of aLineString
Iteration
CoordsIter
: Iterate over the coordinates of a geometryMapCoords
: Map a function over all the coordinates in a geometry, returning a new geometryMapCoordsInplace
: Map a function over all the coordinates in a geometry inplaceTryMapCoords
: Map a fallible function over all the coordinates in a geometry, returning a new geometry wrapped in aResult
Boundary
BoundingRect
: Calculate the axisaligned bounding rectangle of a geometryConcaveHull
: Calculate the concave hull of a geometryConvexHull
: Calculate the convex hull of a geometryExtremes
: Calculate the extreme coordinates and indices of a geometry
Affine transformations
Rotate
: Rotate a geometry around its centroidRotatePoint
: Rotate a geometry around a pointTranslate
: Translate a geometry along its axis
Miscellaneous
Centroid
: Calculate the centroid of a geometryHaversineDestination
:HaversineIntermediate
:Proj
: Project geometries with theproj
crate
Features
The following optional Cargo features are available:
projnetwork
: Enables network grid support for theproj
crate. After enabling this feature, further configuration is required to use the network griduseproj
: Enables coordinate conversion and transformation ofPoint
geometries using theproj
crateuseserde
: 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…
Reexports
pub use crate::algorithm::*; 
Modules
algorithm  This module includes all the functions of geometric calculations 
prelude  A prelude which reexports the traits for manipulating objects in this
crate. Typically imported with 
Macros
geometry_delegate_impl  Implements the common pattern where a Geometry enum simply delegates its trait impl to it’s inner type. 
line_string  Creates a 
point  Creates a 
polygon  Creates a 
Structs
Coordinate  A lightweight struct used to store coordinates on the 2dimensional Cartesian plane. 
GeometryCollection  A collection of 
Line  A line segment made up of exactly two

LineString  An ordered collection of two or more 
MultiLineString  A collection of

MultiPoint  A collection of 
MultiPolygon  A collection of 
Point  A single point in 2D space. 
Polygon  A bounded twodimensional area. 
Rect  An axisaligned bounded 2D rectangle whose area is
defined by minimum and maximum 
Triangle  A bounded 2D area whose three vertices are defined by

Enums
Closest  The result of trying to find the closest spot on an object to a point. 
Geometry  An enum representing any possible geometry type. 
Traits
CoordFloat  
CoordNum  The type of an x or y value of a point/coordinate. 
GeoFloat  A common numeric trait used for geo algorithms. 
GeoNum  
ToGeo  Deprecated 