Skip to content

sudapy.viz.maps

Quick map visualization: export vector or raster data to PNG or interactive HTML.

sudapy.viz.maps

Quick map visualization helpers.

Supports exporting vector or raster data to PNG (static) or HTML (interactive).

quick_map

quick_map(src: PathLike, out: PathLike, *, title: str | None = None) -> Path

Create a quick visualization of a vector or raster dataset.

The output format is determined by the extension of out:

  • .png / .jpg - static image (requires matplotlib).
  • .html - interactive Leaflet map (requires folium).

Parameters:

Name Type Description Default
src PathLike

Input vector or raster file path.

required
out PathLike

Output image/HTML path.

required
title str | None

Optional title for the map.

None

Returns:

Type Description
Path

Path to the generated output.

Source code in src\sudapy\viz\maps.py
def quick_map(
    src: PathLike,
    out: PathLike,
    *,
    title: str | None = None,
) -> Path:
    """Create a quick visualization of a vector or raster dataset.

    The output format is determined by the extension of *out*:

    - ``.png`` / ``.jpg`` - static image (requires matplotlib).
    - ``.html`` - interactive Leaflet map (requires folium).

    Args:
        src: Input vector or raster file path.
        out: Output image/HTML path.
        title: Optional title for the map.

    Returns:
        Path to the generated output.
    """
    src = Path(src)
    out = Path(out)
    if not src.exists():
        raise FileFormatError(f"Input file not found: {src}")

    out.parent.mkdir(parents=True, exist_ok=True)

    if out.suffix.lower() == ".html":
        return _export_html(src, out, title=title)
    else:
        return _export_static(src, out, title=title)