salem.Map

class salem.Map(grid, nx=500, ny=None, factor=None, countries=True, **kwargs)[source]

Plotting georeferenced data.

A Map is an implementation of DataLevels that wraps imshow(), by adding all kinds of geoinformation on the plot. It’s primary purpose is to add country borders or topographical shading. Another purpose is to be able to plot all kind of georeferenced data on an existing map while being sure that the plot is accurate.

In short: the Map is a higher-level, less wordy and less flexible version of cartopy or basemap. It’s usefulness is best shown by the examples in the doc.

For worldwide maps or very flexible plots you’d better use cartopy, because Salem’s Map is constrained by it’s primary objective: plotting regional maps.

__init__(grid, nx=500, ny=None, factor=None, countries=True, **kwargs)[source]

Make a new map.

Parameters:
gridsalem.Grid

the grid defining the map

nxint

x resolution (in pixels) of the map

nyint

y resolution (in pixels) of the map (ignored if nx is set)

factorfloat

shortcut to keep the same image resolution as the grid. 1 prevents image resizing

countriesbool

automatically add country borders to the map (you can do it later with a call to set_shapefile)

kwargs: **

all keywords accepted by DataLevels

Methods

__init__(grid[, nx, ny, factor, countries])

Make a new map.

append_colorbar(ax[, position, size, pad])

Appends a colorbar to existing axes

colorbarbase(cax, **kwargs)

Returns a ColorbarBase to add to the cax axis.

get_colorbarbase_kwargs()

If you need to make a colorbar based on a given DataLevel state.

plot(ax)

Add the map plot to an axis.

set_cmap([cm])

Set a colormap.

set_contour([data, crs, interp])

Adds data to contour on the map.

set_contourf([data, crs, interp])

Adds data to contourfill on the map.

set_data([data, crs, interp, overplot])

Adds data to the plot.

set_extend([extend])

Colorbar extensions: 'neither' | 'both' | 'min' | 'max'

set_geometry([geometry, crs, text, ...])

Adds any Shapely geometry to the map.

set_levels([levels])

Levels you define.

set_lonlat_contours([interval, xinterval, ...])

Add longitude and latitude contours to the map.

set_nlevels([nlevels])

Automatic N levels.

set_norm([norm])

Set a normalization function.

set_plot_params([levels, nlevels, vmin, ...])

Shortcut to all parameters related to the plot.

set_points(x, y, **kwargs)

Shortcut for set_geometry() accepting coordinates as input.

set_rgb([img, crs, interp, natural_earth])

Manually force to a rgb img

set_scale_bar([location, length, maxlen, ...])

Add a legend bar showing the scale to the plot.

set_shapefile([shape, countries, oceans, ...])

Add a shapefile to the plot.

set_text([x, y, text, crs])

Add a text to the map.

set_topography([topo, crs, relief_factor])

Add topographical shading to the map.

set_vmax([val])

Maximum level value.

set_vmin([val])

Mininum level value.

to_rgb()

Transform the data to a RGB image and add topographical shading.

transform([crs, ax])

Get a matplotlib transform object for a given reference system

update(d)

Update the properties of DataLevels from the dictionary d.

visualize([ax, title, orientation, ...])

Quick plot, useful for debugging.

Attributes

extend

Clever getter.

levels

Clever getter.

nlevels

Clever getter.

norm

Clever getter.

vmax

Clever getter.

vmin

Clever getter.