datacube.utils.geometry.Geometry#

class datacube.utils.geometry.Geometry(geom, crs=None)[source]#

2D Geometry with CRS

Instantiate with a GeoJSON structure

If 3D coordinates are supplied, they are converted to 2D by dropping the Z points.

__init__(geom, crs=None)[source]#

Methods

__init__(geom[, crs])

buffer(distance[, resolution])

rtype

Geometry

clone()

rtype

Geometry

contains(other)

rtype

bool

crosses(other)

rtype

bool

difference(other)

rtype

Geometry

disjoint(other)

rtype

bool

interpolate(distance)

Returns a point distance units along the line.

intersection(other)

rtype

Geometry

intersects(other)

rtype

bool

overlaps(other)

rtype

bool

segmented(resolution)

Possibly add more points to the geometry so that no edge is longer than resolution.

simplify(tolerance[, preserve_topology])

rtype

Geometry

split(splitter)

rtype

Iterable[Geometry]

svg()

rtype

str

symmetric_difference(other)

rtype

Geometry

to_crs(crs[, resolution, wrapdateline])

Convert geometry to a different Coordinate Reference System

touches(other)

rtype

bool

transform(func)

Applies func to all coordinates of Geometry and returns a new Geometry of the same type and in the same projection from the transformed coordinates.

union(other)

rtype

Geometry

within(other)

rtype

bool

Attributes

area

float

boundary

Geometry

boundingbox

BoundingBox

centroid

Geometry

convex_hull

Geometry

coords

List[Tuple[float, float]]

envelope

Geometry

exterior

Geometry

interiors

List[Geometry]

is_empty

bool

is_valid

bool

json

length

float

points

List[Tuple[float, float]]

type

str

wkt

str

xy

Tuple[array, array]

Methods:

interpolate(distance)

Returns a point distance units along the line.

segmented(resolution)

Possibly add more points to the geometry so that no edge is longer than resolution.

split(splitter)

rtype

Iterable[Geometry]

to_crs(crs[, resolution, wrapdateline])

Convert geometry to a different Coordinate Reference System

transform(func)

Applies func to all coordinates of Geometry and returns a new Geometry of the same type and in the same projection from the transformed coordinates.

interpolate(distance)[source]#

Returns a point distance units along the line. Raises TypeError if geometry doesn’t support this operation.

Return type

Geometry

segmented(resolution)[source]#

Possibly add more points to the geometry so that no edge is longer than resolution.

Return type

Geometry

split(splitter)[source]#
Return type

Iterable[Geometry]

to_crs(crs, resolution=None, wrapdateline=False)[source]#

Convert geometry to a different Coordinate Reference System

Parameters
  • crs (Union[str, CRS, CRS, Dict[str, Any]]) – CRS to convert to

  • resolution (Optional[float]) – Subdivide the geometry such it has no segment longer then the given distance. Defaults to 1 degree for geographic and 100km for projected. To disable completely use Infinity float(‘+inf’)

  • wrapdateline (bool) – Attempt to gracefully handle geometry that intersects the dateline when converting to geographic projections. Currently only works in few specific cases (source CRS is smooth over the dateline).

Return type

Geometry

transform(func)[source]#

Applies func to all coordinates of Geometry and returns a new Geometry of the same type and in the same projection from the transformed coordinates.

func maps x, y, and optionally z to output xp, yp, zp. The input parameters may be iterable types like lists or arrays or single values. The output shall be of the same type: scalars in, scalars out; lists in, lists out.

Return type

Geometry