API reference

magpye.GeoMap(*args, **kwargs)

Class for designing and plotting geospatial maps.

class magpye.GeoMap(*args, **kwargs)

Class for designing and plotting geospatial maps.

Parameters
  • area_name (str, optional) – The name of a an area (e.g. ‘europe’) with a pre-configured projection and extent - see examples for a sample of valid area names.

  • projection (str, optional) – The name of the map projection to use for this map. See examples for a sample of valid projections.

  • extent (tuple, optional) – A four-element list/tuple containing the latitude and longitude extents to use in the map. These must be provided in the order: lower- left latitude, lower-left longitude, upper-right latitude, upper-right longitude.

arrows(*, u=None, v=None, speed=None, direction=None, shaded=False, style=None, **kwargs)

Plot arrows on a map.

coastlines(*args, **kwargs)

Add coastlines to the map.

Parameters
  • resolution (str, default='low') – The resolution of the coastlines to be included in the map. Must be one of ‘low’, ‘medium’ or ‘high’.

  • line_colour (str, default='black') – Either a hexadecimal colour or a named colour to use for the coastlines.

  • line_style (str, default='solid') – One of ‘solid’, ‘dash’, ‘dot’, ‘chain_dash’, or ‘chain_dot’.

  • line_thickness (float, default=1.0) – The thickness of the coastlines.

  • land_colour (str, optional) – Either a hexadecimal colour or a named colour to use for the fill colour of areas within coastline polygons (i.e. land).

  • ocean_colour (str, optional) – Either a hexadecimal colour or a named colour to use for the fill colour of areas outside coastlines (i.e. oceans).

contour_lines(source, *args, style=None, **kwargs)

Plot line contours on a map.

contour_shaded(source, *args, style=None, **kwargs)

Plot filled contours on a map.

footer(*args, **kwargs)

Add a footer to the bottom of the plot, containing text and/or a logo.

Parameters
  • text (str, optional) – A string of text to include in the footer.

  • font (str, default='sansserif') – The name of the font to use for footer text.

  • font_style (str, default='normal') – Style options for the footer font, e.g. ‘bold’.

  • font_size (float, optional) – The font size to use, in cm.

  • font_colour (str, default='charcoal') – Either a hexadecimal colour or a named colour to use for the footer font.

  • logo (bool or str, optional) – The name of an organisation or project whose logo should be added to the footer. Must be one of ‘ecmwf’, ‘c3s’ or ‘cams’ - or False if no logo should be included (default).

  • datestamp (bool, optional) – If True, the date and time at which the map was generated will be included in the footer text.

gridlines(*args, **kwargs)

Add gridlines to the map.

Parameters
  • lat_frequency (float, default=10) – The interval in degrees of latitude between each latitude grid line.

  • lon_frequency (float, default=20) – The interval in degrees of longitude between each longitude grid line.

  • lat_reference (float, default=0) – The reference/starting latitude from which to begin drawing latitude lines at a frequency given by lat_frequency.

  • lon_reference (float, default=0) – The reference/starting longitude from which to begin drawing longitude lines at a frequency given by lon_frequency.

  • line_colour (str, default='blue') – Either a hexadecimal colour or a named colour to use for the river lines.

  • line_style (str, default='solid') – One of ‘solid’, ‘dash’, ‘dot’, ‘chain_dash’, or ‘chain_dot’.

  • line_thickness (float, default=1.0) – The thickness of the river lines.

  • labels (bool, optional) – If True, gridlines will be given latitude and longitude labels.

  • label_font (str, default='sansserif') – The name of the font to use for gridline label text.

  • label_font_size (float, optional) – The font size to use, in cm.

  • label_font_colour (str, default='charcoal') – Either a hexadecimal colour or a named colour to use for the gridline label font.

  • label_latitude_frequency (int, optional) – The frequency at which to label latitude gridlines. A frequency of 1 means every latitude gridline will be labelled.

  • label_longitude_frequency (int, optional) – The frequency at which to label longitude gridlines. A frequency of 1 means every longitude gridline will be labelled.

  • label_top_edge (bool, default=True) – If True, labels will be drawn where gridlines intersect the top edge/border of the map.

  • label_bottom_edge (bool, default=True) – If True, labels will be drawn where gridlines intersect the bottom edge/border of the map.

  • label_left_edge= (bool, default=True) – If True, labels will be drawn where gridlines intersect the left edge/border of the map.

  • label_right_edge (bool, default=True) – If True, labels will be drawn where gridlines intersect the right edge/border of the map.

rivers(*args, **kwargs)

Add rivers to the map.

Parameters
  • resolution (str, default='low') – The resolution of the rivers to be included in the map. Must be one of ‘low’, ‘medium’ or ‘high’.

  • line_colour (str, default='blue') – Either a hexadecimal colour or a named colour to use for the river lines.

  • line_style (str, default='solid') – One of ‘solid’, ‘dash’, ‘dot’, ‘chain_dash’, or ‘chain_dot’.

  • line_thickness (float, default=1.0) – The thickness of the river lines.

title(text, **kwargs)

Add a title above the map.