Skip to main content

qgis-map

image

A Python library that provides a high-level, leafmap-like API for working with PyQGIS

Features

  • High-level API: Simple, intuitive methods inspired by leafmap
  • Basemap support: Easy access to OpenStreetMap, Esri, Google, CartoDB, and more
  • Vector layers: Add shapefiles, GeoJSON, GeoPackage, and other vector formats
  • Raster layers: Add GeoTIFFs, COGs, and apply color ramps
  • Time slider: Create interactive time-based visualizations with dockable panels
  • Dockable panels: Create custom interactive panels in QGIS

Installation

pip install qgis-map

Quick Start

Use qgis-map within the QGIS Python console or in a PyQGIS script:

from qgis_map import Map

# Create a map with a basemap
m = Map(basemap="OpenStreetMap")

# Add vector data
m.add_vector("path/to/data.geojson", layer_name="My Data", zoom_to_layer=True)

# Add raster data with a color ramp
m.add_raster("path/to/dem.tif", colormap="terrain", layer_name="Elevation")

Usage Examples

Adding Basemaps

from qgis_map import Map, get_basemap_names

# See all available basemaps
print(get_basemap_names())

# Create map with a basemap
m = Map(basemap="CartoDB.DarkMatter")

# Add additional basemaps
m.add_basemap("Esri.WorldImagery", layer_name="Satellite")
m.add_basemap("HYBRID")  # Google Hybrid

# Add custom XYZ tiles
m.add_basemap(
    "https://custom.tiles.server/{z}/{x}/{y}.png",
    layer_name="Custom Tiles"
)

Adding Vector Layers

from qgis_map import Map

m = Map()

# Add a shapefile
m.add_vector("countries.shp", layer_name="Countries")

# Add GeoJSON with styling
m.add_vector(
    "cities.geojson",
    layer_name="Cities",
    style={
        "color": "#3388ff",
        "stroke_color": "#000000",
        "stroke_width": 1
    },
    zoom_to_layer=True
)

# Add a GeoDataFrame
import geopandas as gpd
gdf = gpd.read_file("data.gpkg")
m.add_gdf(gdf, layer_name="My GeoDataFrame")

Adding Raster Layers

from qgis_map import Map

m = Map()

# Add a GeoTIFF
m.add_raster("elevation.tif", layer_name="DEM")

# Add with color ramp
m.add_raster(
    "temperature.tif",
    colormap="RdYlBu",
    vmin=-10,
    vmax=40,
    layer_name="Temperature"
)

# Add a Cloud Optimized GeoTIFF (COG)
m.add_cog(
    "https://example.com/data.tif",
    layer_name="Remote COG",
    zoom_to_layer=True
)

# Add a WMS layer
m.add_wms(
    url="https://ows.mundialis.de/services/service",
    layers="TOPO-OSM-WMS",
    layer_name="Topo WMS"
)

Time Slider

from qgis_map import Map

m = Map()

# Create a time slider to switch between layers
layers = {
    "2020": "data/ndvi_2020.tif",
    "2021": "data/ndvi_2021.tif",
    "2022": "data/ndvi_2022.tif",
    "2023": "data/ndvi_2023.tif",
}
m.add_time_slider(layers=layers, time_interval=2)

Utility Methods

from qgis_map import Map

m = Map()
m.add_basemap("OpenStreetMap")
m.add_vector("data.geojson", layer_name="My Layer")

# Get layer names
print(m.get_layer_names())

# Zoom to a layer
m.zoom_to_layer("My Layer")

# Zoom to bounds
m.zoom_to_bounds((-122.5, 37.5, -121.5, 38.5))

# Set center and zoom
m.set_center(lat=37.7749, lon=-122.4194, zoom=12)

# Remove a layer
m.remove_layer("My Layer")

# Clear all layers (keep basemap)
m.clear_layers(keep_basemap=True)

# Export to image
m.to_image("output.png", width=1920, height=1080)

Creating Custom Dock Widgets

from qgis_map import Map
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget

m = Map()

# Create a custom widget
widget = QWidget()
layout = QVBoxLayout()
layout.addWidget(QLabel("Custom Panel Content"))
widget.setLayout(layout)

# Add as dockable panel
dock = m.create_dock_widget("My Panel", widget, position="right")

Available Basemaps

  • OpenStreetMap: OpenStreetMap, OSM
  • CartoDB: CartoDB.Positron, CartoDB.DarkMatter, CartoDB.Voyager
  • Stadia/Stamen: Stadia.StamenToner, Stadia.StamenTerrain, Stadia.StamenWatercolor
  • Esri: Esri.WorldStreetMap, Esri.WorldImagery, Esri.WorldTopoMap, Esri.WorldTerrain, Esri.NatGeoWorldMap, Esri.OceanBasemap
  • Google: ROADMAP, SATELLITE, TERRAIN, HYBRID
  • Other: OpenTopoMap

API Reference

See the full API documentation for detailed information about all available methods.

Credits

This package was inspired by leafmap and is built on PyQGIS.

Metadata

Release files for qgis-map 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qgis-map 0.2.0
File Size Uploaded
qgis_map-0.2.0.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qgis-map 0.2.0
File Interpreter ABI Platform
qgis_map-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 46.9 kB

Release files / qgis_map-0.2.0.tar.gz

Download URL qgis_map-0.2.0.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
877ed91aaf8d8202d650ca790f68d34680e881e914313d52cc4b6edaf5d16b17
BLAKE2b-256 checksum
How to use checksums
522715a8cc93bd5fa6ee78f43ce6bff978bb1c0ea9222b87230b8c9dcb4f5435
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / qgis_map-0.2.0-py2.py3-none-any.whl

Download URL qgis_map-0.2.0-py2.py3-none-any.whl
Size 17.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2b4e0e0cb4c7fff134b0108840fc89447c2983b4890e9acf85f68bc8c00770df
BLAKE2b-256 checksum
How to use checksums
2f0c8535af5b9c6ae56ab7a73524d3379bd961141cd097b7d7399daa1751ad16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page