map_draw#

map_draw(lon_min, lon_max, lat_min, lat_max, title, lon_data, lat_data, data_draw, path_save, name_save, data_min=None, data_max=None, custom_coastline=None, layer_name=None)[source]#

Draw a 2D geospatial field on a Mercator map using Basemap and save it as a PNG image.

The function plots a rectangular region bounded by the given longitude and latitude limits, with grid lines and coastlines automatically drawn. The data range is scaled between the 5th and 95th percentiles (unless manually specified) and padded by 10% for better visual contrast.

Parameters:
  • lon_min (float) – Minimum and maximum longitude boundaries of the map.

  • lon_max (float) – Minimum and maximum longitude boundaries of the map.

  • lat_min (float) – Minimum and maximum latitude boundaries of the map.

  • lat_max (float) – Minimum and maximum latitude boundaries of the map.

  • title (str) – Title of the map.

  • lon_data (np.ndarray) – 2D array of longitudes (same shape as data_draw).

  • lat_data (np.ndarray) – 2D array of latitudes (same shape as data_draw).

  • data_draw (np.ndarray) – 2D array of scalar values to plot (e.g., temperature, precipitation).

  • path_save (str) – Directory path where the output PNG will be saved.

  • name_save (str) – Base filename (without extension) for the saved image.

  • data_min (float, optional) – User-specified minimum and maximum color limits. If None, they are derived from the 5th and 95th percentiles of data_draw.

  • data_max (float, optional) – User-specified minimum and maximum color limits. If None, they are derived from the 5th and 95th percentiles of data_draw.

  • custom_coastline (str, optional) – User-specified path of the custom coastline If None, they are derived from the default map of Basemap library

  • layer_name (str, optional) – Name of the layer of the custom shapefile to draw

Return type:

None

Examples

See Example 1: Load a list and create a map