Geometric Primitives#

Geometric primitives and spatial algorithms.

This module provides a comprehensive set of geometric primitives (points, lines, polygons) and spatial algorithms. It is built on the Boost.Geometry library and organized into two namespaces based on the coordinate system:

  • Geographic: For coordinates on the Earth’s surface (Long/Lat). Calculations account for the Earth’s curvature (ellipsoid/sphere).

  • Cartesian: For planar coordinates (X/Y). Calculations use Euclidean geometry.

Note

The API is symmetrical: both namespaces provide the same classes (e.g., Point, Polygon) and algorithms (e.g., intersection, distance), but their internal implementation differs to suit the coordinate system.

Geographic System#

Geographic (spherical/ellipsoidal) geometry.

Primitives#

Data structures for representing spatial features defined by Longitude and Latitude.

Point(self[, lon, lat])

A point in geodetic coordinates (longitude, latitude).

Segment(self[, a, b])

A segment in geographic coordinates.

LineString(, writable=False], lat, shape=, ...)

A linestring in geographic coordinates.

Ring(, writable=False], lat, shape=, ...)

A ring (closed linestring) in geographic coordinates.

Box(self[, min_corner, max_corner])

A box (rectangle) in geographic coordinates.

Polygon(self[, exterior, interiors])

A polygon in geographic coordinates.

MultiPoint(, writable=False], lats, shape=, ...)

A collection of points in geographic coordinates.

MultiLineString(self[, lines])

A collection of linestrings in geographic coordinates.

MultiPolygon(self[, polygons])

A collection of polygons in geographic coordinates.

Coordinate Reference Systems#

Classes for managing coordinate conversions and defining the Earth’s shape.

Coordinates(self[, spheroid])

Create a coordinate transformation system.

Spheroid()

Define a reference ellipsoid for geodetic calculations.

Spatial Indexing#

R-Tree spatial index implementation for geographic coordinates.

RTree(self)

Spatial index for geographic longitude/latitude points.

Algorithms#

Spatial operations and predicates.

algorithms.area(...)

Calculate the area of a geometric object.

algorithms.azimuth(point1, point2[, ...])

Calculate the azimuth from point1 to point2.

algorithms.centroid(...)

Calculate the centroid of a geometry.

algorithms.clear(...)

Clears a geometry, removing all points.

algorithms.closest_points(...)

Calculate the closest points between two geometries.

algorithms.convert_to_cartesian(...)

Converts a Geographic geometry to Cartesian coordinates.

algorithms.convex_hull(...)

Calculates the convex hull of a geometry.

algorithms.correct(...)

Corrects a geometry to make it valid according to OGC rules.

algorithms.covered_by(...)

Checks if the first geometry is covered by the second geometry.

algorithms.crosses(...)

Checks if the first geometry crosses the second geometry.

algorithms.curvilinear_distance(...[, ...])

Calculate the curvilinear distance along the geometric object.

algorithms.densify(...)

Densifies a geometry by adding points along segments.

algorithms.difference(...)

Computes the geometric difference between two geometries.

algorithms.disjoint(...)

Checks if two geometries are disjoint (do not intersect).

algorithms.distance(...)

Calculate the distance between two geometric objects.

algorithms.envelope(...)

Calculates the envelope (bounding box) of a geometry.

algorithms.equals(...)

Checks if two geometries are spatially equal.

algorithms.intersection(...)

Computes the geometric intersection between two geometries.

algorithms.intersects(...)

Checks if two geometries intersect (have at least one point in common).

algorithms.is_empty(...)

Check if a geometry is empty (contains no points).

algorithms.is_simple(...)

Check if a geometry is simple (has no self-intersections).

algorithms.is_valid(...)

Check if a geometry is valid according to OGC standards.

algorithms.length(...)

Calculate the length of a geometric object.

algorithms.line_interpolate(...)

Returns a point at the specified distance along a linestring.

algorithms.overlaps(...)

Checks if two geometries overlap.

algorithms.perimeter(-> float  -> float)

Calculates the perimeter of an areal geometry.

algorithms.relate(...)

Checks if two geometries satisfy a DE-9IM (Dimensionally Extended nine-Intersection Model) relationship mask.

algorithms.relation(...)

Computes the DE-9IM (Dimensionally Extended nine-Intersection Model) matrix for two geometries.

algorithms.reverse(...)

Reverses the order of points in a geometry.

algorithms.simplify(...)

Simplifies a geometry by removing points based on distance tolerance.

algorithms.touches(...)

Checks if two geometries touch (have at least one boundary point in common, but no interior points).

algorithms.transform_to_box(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_linestring(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_multilinestring(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_multipoint(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_multipolygon(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_point(geometry)

Transform a geometry to a different geometry type.

algorithms.transform_to_polygon(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_ring(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_segment(geometry)

Transform a geometry to a different geometry type.

algorithms.union(...)

Computes the geometric union of two geometries.

algorithms.unique(...)

Removes consecutive duplicate points from a geometry.

algorithms.within(...)

Checks if the first geometry is completely within the second geometry.

Vectorized Predicates#

Vectorized spatial predicates for geographic geometries.

algorithms.for_each_point_within(...[, ...])

Test if each point in a source geometry is within a container geometry.

algorithms.for_each_point_covered_by(...[, ...])

Test if each point in a source geometry is covered by a container geometry.

algorithms.for_each_point_distance(...[, ...])

Calculate the distance from each point in a source geometry to a target geometry.

Distance Strategies#

Strategies for computing geodesic distances on the Earth’s surface.

algorithms.Strategy(*values)

Geodetic calculation strategy.

algorithms.ANDOYER

Andoyer method

algorithms.KARNEY

Karney method

algorithms.THOMAS

Thomas method

algorithms.VINCENTY

Vincenty method (default)

Cartesian System#

Cartesian (planar) geometry.

Primitives#

Data structures for representing spatial features defined by X and Y coordinates.

Point(self[, x, y])

A point in Cartesian coordinates.

Segment()

A segment in Cartesian coordinates.

LineString(, writable=False], ys, shape=, ...)

A linestring in Cartesian coordinates.

Ring(, writable=False], ys, shape=, ...)

A ring (closed linestring) in Cartesian coordinates.

Box(self[, min_corner, max_corner])

A box (rectangle) in Cartesian coordinates.

Polygon()

A polygon in Cartesian coordinates.

MultiPoint(, writable=False], ys, shape=, ...)

A collection of points in Cartesian coordinates.

MultiLineString(self[, lines])

A collection of linestrings in Cartesian coordinates.

MultiPolygon(self[, polygons])

A collection of polygons in Cartesian coordinates.

Algorithms#

Spatial operations and predicates in Euclidean space.

algorithms.area(...)

Calculate the area of a geometric object in Cartesian coordinates.

algorithms.azimuth(point1, point2)

Calculate the azimuth from point1 to point2.

algorithms.buffer(...)

Calculate the buffer of a geometry.

algorithms.centroid(...)

Calculate the centroid of a geometry.

algorithms.clear(...)

Clears a geometry, removing all points.

algorithms.closest_points(...)

Calculate the closest points between two geometries.

algorithms.convert_to_geographic(...)

Converts a Cartesian geometry to Geographic coordinates.

algorithms.convex_hull(...)

Calculates the convex hull of a geometry.

algorithms.correct(...)

Corrects a geometry to make it valid according to OGC rules.

algorithms.covered_by(...)

Checks if the first geometry is covered by the second geometry.

algorithms.crosses(...)

Checks if the first geometry crosses the second geometry.

algorithms.densify(...)

Densifies a geometry by adding points along segments.

algorithms.difference(...)

Computes the geometric difference between two geometries.

algorithms.disjoint(...)

Checks if two geometries are disjoint (do not intersect).

algorithms.distance(...)

Calculates the distance between two geometries.

algorithms.envelope(...)

Calculates the envelope (bounding box) of a geometry.

algorithms.equals(...)

Checks if two geometries are spatially equal.

algorithms.intersection(...)

Computes the geometric intersection between two geometries.

algorithms.intersects(...)

Checks if two geometries intersect (have at least one point in common).

algorithms.is_empty(...)

Check if a geometry is empty (contains no points).

algorithms.is_simple(...)

Check if a geometry is simple (has no self-intersections).

algorithms.is_valid(...)

Check if a geometry is valid according to OGC standards.

algorithms.length(...)

Calculates the length of a geometry.

algorithms.line_interpolate(...)

Returns a point at the specified distance along a linestring.

algorithms.overlaps(...)

Checks if two geometries overlap.

algorithms.perimeter(...)

Calculates the perimeter of an areal geometry.

algorithms.relate(...)

Checks if two geometries satisfy a DE-9IM (Dimensionally Extended nine-Intersection Model) relationship mask.

algorithms.relation(...)

Computes the DE-9IM (Dimensionally Extended nine-Intersection Model) matrix for two geometries.

algorithms.reverse(...)

Reverses the order of points in a geometry.

algorithms.simplify(...)

Simplifies a geometry using the Douglas-Peucker algorithm.

algorithms.touches(...)

Checks if two geometries touch (have at least one boundary point in common, but no interior points).

algorithms.transform_to_box(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_linestring(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_multilinestring(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_multipoint(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_multipolygon(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_point(geometry)

Transform a geometry to a different geometry type.

algorithms.transform_to_polygon(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_ring(...)

Transform a geometry to a different geometry type.

algorithms.transform_to_segment(geometry)

Transform a geometry to a different geometry type.

algorithms.union(...)

Computes the geometric union of two geometries.

algorithms.unique(...)

Removes consecutive duplicate points from a geometry.

algorithms.within(...)

Checks if the first geometry is completely within the second geometry.

Vectorized Predicates#

Vectorized spatial predicates for Cartesian geometries.

algorithms.for_each_point_within(...[, ...])

Test if each point in a source geometry is within a container geometry.

algorithms.for_each_point_covered_by(...[, ...])

Test if each point in a source geometry is covered by a container geometry.

algorithms.for_each_point_distance(...[, ...])

Calculate the distance from each point in a source geometry to a target geometry.

Buffer Strategies#

Configuration for the buffering algorithm (Cartesian only).

algorithms.DistanceAsymmetric(self, ...)

Create asymmetric distance strategy

algorithms.DistanceSymmetric(self, ...)

Create symmetric distance strategy

algorithms.EndFlat(self)

Create flat end strategy

algorithms.EndRound(self[, points_per_circle])

Create rounded end strategy

algorithms.JoinMiter(self[, miter_limit])

Create miter join strategy

algorithms.JoinRound(self[, points_per_circle])

Create rounded join strategy

algorithms.PointCircle(self[, points_per_circle])

Create circular point strategy

algorithms.PointSquare(self)

Create square point strategy

algorithms.SideStraight(self)

Create straight side strategy

Satellite-Specific#

Satellite-specific geometric operations such as swath calculation and crossover finding.

calculate_swath(lon_nadir[, shape, ...])

Calculate the swath coordinates from the nadir coordinates.

find_crossovers(lon1[, shape, writable, ...])

Find crossover point between two satellite half-orbits.