Skip to content

Vector Overlays (extra_vectors)

The extra_vectors parameter is one of the most powerful features of geoplot-themes. It allows you to overlay an infinite number of vector layers (shapefiles) onto your base map.

What makes this special is that it uses ggnewscale to ensure that every layer has its own independent legend.

Usage

You pass a list of dictionaries to extra_vectors. Each dictionary represents a single spatial layer.

python
extra_vectors = [
    {
        "data": "C:/data/swamp.shp",
        "name": "Wetlands",
        "fill": "#2d5a27",
        "alpha": 0.6
    },
    {
        "data": "C:/data/river.shp",
        "name": "Rivers",
        "color": "#1f78b4",
        "linewidth": 1.2
    }
]

Dictionary Keys

KeyTypeDescription
datastringAbsolute or relative path to the vector file (.shp, .geojson).
namestringThe label that will appear in the legend for this layer.
colorstring (hex)The outline or line color (e.g. #1f78b4). Use "NA" for no outline.
fillstring (hex)The fill color for polygons. Use "NA" for hollow polygons.
alphafloatTransparency from 0.0 (invisible) to 1.0 (opaque).
linewidthfloatThickness of the lines or polygon borders.

Released under the MIT License.