cartopy.crs.CRS#

class cartopy.crs.CRS(proj4_params, globe=None)[source]#

Bases: CustomConstructorCRS

Define a Coordinate Reference System using proj. The cartopy.crs.CRS class is the very core of cartopy, all coordinate reference systems in cartopy have CRS as a parent class.

Parameters:
  • proj4_params (iterable of key-value pairs) – The proj4 parameters required to define the desired CRS. The parameters should not describe the desired elliptic model, instead create an appropriate Globe instance. The proj4_params parameters will override any parameters that the Globe defines.

  • globe (Globe instance, optional) – If omitted, the default Globe instance will be created. See Globe for details.

as_geocentric()[source]#

Return a new Geocentric CRS with the same ellipse/datum as this CRS.

as_geodetic()[source]#

Return a new Geodetic CRS with the same ellipse/datum as this CRS.

transform_point(x, y, src_crs)[source]#

Transform the given float64 coordinate pair, in the given source coordinate system (src_crs), to this coordinate system.

Parameters:
  • x – the x coordinate, in src_crs coordinates, to transform

  • y – the y coordinate, in src_crs coordinates, to transform

  • src_crs – instance of CRS that represents the coordinate system of x and y.

  • trap – Whether proj errors for “latitude or longitude exceeded limits” and “tolerance condition error” should be trapped.

Returns:

(x, y) in this coordinate system

transform_points(src_crs, x, y[, z])[source]#

Transform the given coordinates, in the given source coordinate system (src_crs), to this coordinate system.

Parameters:
  • src_crs – instance of CRS that represents the coordinate system of x, y and z.

  • x – the x coordinates (array), in src_crs coordinates, to transform. May be 1 or 2 dimensional.

  • y – the y coordinates (array), in src_crs coordinates, to transform. Its shape must match that of x.

  • z (optional) – the z coordinates (array), in src_crs coordinates, to transform. Defaults to None. If supplied, its shape must match that of x.

  • trap – Whether proj errors for “latitude or longitude exceeded limits” and “tolerance condition error” should be trapped.

Returns:

Array of shape x.shape + (3, ) in this coordinate system.

transform_vectors(src_proj, x, y, u, v)[source]#

Transform the given vector components, with coordinates in the given source coordinate system (src_proj), to this coordinate system. The vector components must be given relative to the source projection’s coordinate reference system (grid eastward and grid northward).

Parameters:
  • src_proj – The CRS.Projection that represents the coordinate system the vectors are defined in.

  • x – The x coordinates of the vectors in the source projection.

  • y – The y coordinates of the vectors in the source projection.

  • u – The grid-eastward components of the vectors.

  • v – The grid-northward components of the vectors.

Note

x, y, u and v may be 1 or 2 dimensional, but must all have matching shapes.

Returns:

ut, vt (The transformed vector components.)

Note

The algorithm used to transform vectors is an approximation rather than an exact transform, but the accuracy should be good enough for visualization purposes.