cartopy.geodesic.Geodesic#

class cartopy.geodesic.Geodesic(radius=6378137.0, flattening=0.0033528106647474805)[source]#

Define an ellipsoid on which to solve geodesic problems.

Parameters:
  • radius (float, optional) – Equatorial radius (metres). Defaults to the WGS84 semimajor axis (6378137.0 metres).

  • flattening (float, optional) – Flattening of ellipsoid. Setting flattening = 0 gives a sphere. Negative flattening gives a prolate ellipsoid. If flattening > 1, set flattening to 1/flattening. Defaults to the WGS84 flattening (1/298.257223563).

circle(lon, lat, radius, n_samples=180, endpoint=False)[source]#

Find a geodesic circle of given radius at a given point.

Parameters:
  • lon (float) – Longitude coordinate of the centre.

  • lat (float) – Latitude coordinate of the centre.

  • radius (float) – The radius of the circle (metres).

  • n_samples (int, optional) – Integer number of sample points of circle.

  • endpoint (bool, optional) – Whether to repeat endpoint at the end of returned array.

Returns:

numpy.ndarray, shape=(n_samples, 2) – The evenly spaced longitude-latitude points on the circle.

direct(points, azimuths, distances)[source]#

Solve the direct geodesic problem where the length of the geodesic is specified in terms of distance.

Can accept and broadcast length 1 arguments. For example, given a single start point and distance, an array of different azimuths can be supplied to locate multiple endpoints.

Parameters:
  • points (array_like, shape=(n or 1, 2)) – The starting longitude-latitude point(s) from which to travel.

  • azimuths (float or array_like with shape=(n, )) – List of azimuth values (degrees).

  • distances (float or array_like with shape(n, )) – List of distances values (metres).

Returns:

numpy.ndarray, shape=(n, 3) – The longitudes, latitudes, and forward azimuths of the located endpoint(s).

geometry_length(geometry)[source]#

Return the distance (in physical meters) of the given Shapely geometry.

The geometry is assumed to be in spherical (lon, lat) coordinates.

Parameters:

geometry (shapely.geometry.BaseGeometry) – The Shapely geometry to compute the length of. For polygons, the exterior length will be calculated. For multi-part geometries, the sum of the parts will be computed.

inverse(points, endpoints)[source]#

Solve the inverse geodesic problem.

Can accept and broadcast length 1 arguments. For example, given a single start point, an array of different endpoints can be supplied to find multiple distances.

Parameters:
  • points (array_like, shape=(n or 1, 2)) – The starting longitude-latitude point(s) from which to travel.

  • endpoints (array_like, shape=(n or 1, 2)) – The longitude-latitude point(s) to travel to.

Returns:

numpy.ndarray, shape=(n, 3) – The distances, and the (forward) azimuths of the start and end points.