MapFrame

Luo_Suppe2026-11-20

gma.carto.plot.MapFrame

[class] MapFrame(ax = None, crs = "WGS84", bounds = None):

Main entry of cartography: from gma.carto.plot import MapFrame.

Initialize a map frame for plotting a map!

Optional:

ax = None or matplotlib.~.AxesSubplot. Default None.

A matplotlib subplot. If None, a default axes will be created.

crs = str, int or a class of SpatRef/SpatialReference. Default 'WGS84'.

Base map coordinate system. All data that added to this frame will be reprojected

to this coordinate system. Can be EPSG, WKT, Proj4 and other types of coordinate

characters or SpatRef/SpatialReference class.

bounds = list or None. Default None.

Plot [left, bottom, right, top] extent(In WGS84). All data that added to this map

frame will be clipped to this extent. Default(None) is the maximum extent supported

by the base map coordinate system.

Method

add_appearance(map_app = "CompassNormal1", loc = (0, 0), size = 0.3)

Add a map appearance to this map frame.

Optional:

map_app = str. Default 'CompassNormal1'.

Map appearance type. For more, see ~.appearance.MapAppearance.

loc = tuple. Default (0, 0).

The location of the map appearance. The coordinate system is the same as the map frame.

size = float. Default 0.3.

The size of the map appearance. The unit is the same as the map frame.

**kwargs:

Other parameters passed to ~.appearance.MapAppearance.plot.

Returns:

Type: ~.appearance.MapAppearance.

add_graticule(lon_range = range(-180, 180, 30), lat_range = range(-90, 90, 15))

Add longitude and latitude grid.

Optional:

lon_range = list or range. Default range(-180, 180, 30).

Grid longitude value.

lat_range = list or range. Default range(-90, 90, 15).

Grid latitude value.

**kwargs:

Other parameters passed to matplotlib.collections.Collections.

Returns:

Type: ~appearances.Graticule.

add_vector(vector, facecolors = "#BED2FF", edgecolors = "#B2B2B2", hatchs = None, hatchs_linewidths = None, linewidths = None, linestyles = "solid", pointmarkers = "o", pointsizes = None)

Add a map vector(Layer/Feature/Geometry) to this map frame.

Parameters:

vector: Layer, Feature or Geometry.

A vector object to be added to this map frame.

Optional:

facecolors = str, tuplt, list. Default '#BED2FF'.

Polygon fill color. Only for 'Polygon' or 'Point' geometries. If it is a list,

assign a different color to each feature's geometry. For more, matplotlib.colors.

edgecolors = str, tuplt, list. Default '#B2B2B2'.

The edge or line color. If it is a list, assign a different color to each feature's geometry.

For more, matplotlib.colors.

hatchs = str, list or None. Default None.

Polygon fill style. Only for 'Polygon' geometries. May be {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

or a combination thereof. Default(None) no filling style. If it is a list, assign a different hatch to

each feature. For more, see matplotlib.hatch.

hatchs_linewidths = str, list or None. Default None.

Hatch line width. Only for 'Polygon' geometries. If it is a list, assign a different line width to each hatch.

linewidths = float or list. Default None.

The edge or line width. If it is a list, assign a different line width to each feature's geometry.

linestyles = str, list or tuple. Default 'solid'.

The edge or line style. Only for 'Polygon' or 'Line' geometries. May be {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}. If it is a list,

assign a different line style to each feature's geometry. For more, see matplotlib.lines.lineStyles.

pointmarkers = str, list. Default 'o'.

The point marker. Only for 'Point' geometries. May be {'.', ',', 'o', 'v', '^', '<', '>', '1', '2',

'3', '4', '8', 's', 'p', 'P', '*', 'h', 'H', '+', 'x', 'X', 'D', 'd', '|', '_', 0, 1, 2, 3, 4,

5, 6, 7, 8, 9, 10, 11, 'None', ' ', '', '$...$', Path, ...}. If it is a list, assign a different

marker to each feature's geometry. For more, see matplotlib.lines.lineMarkers.

pointsizes = float, list or None. Default None.

The point size. Only for 'Point' geometries. If it is a list, assign a different size to each feature's geometry.

**kwargs:

Other parameters passed to matplotlib.collections.Collections.

Returns:

Type: ~.vector.PlotVector.

add_raster(raster, bands = None, cmap = None)

Add a discrete dataset to the map frame.

Parameters:

raster: A gma Dataset.

A raster object to be added to this map frame.

Optional:

bands = int, list or None. Default None.

The band ID to be plotted. For multi-band data, only 1, 3 (RGB), and 4 (RGBA) bands are

supported for selection. Duplicate bands will only keep one. Default is the first four bands.

cmap = str, list, matplotlib.color.Colormap or None. Default None.

color map. For more, see matplotlib.color.Colormap.

*Note:

1. If CMap is a list, the list must be in the format (R, G, B),(R, G, B, A) or HEX colors!

Otherwise, create your own matplotlib cmap!

2. If the input dataset has a color table, do not configure CMap, otherwise the dataset

color table will be ignored. Color priority: CMap > ColorTable.

**kwargs:

Other parameters passed to matplotlib.image.AxesImage.

Returns:

Type: ~.raster.PlotRaster.

Inherits all methods from MapFrameBase.

Last Updated 11/21/2026, 2:33:17 AM