home / skills / dkyazzentwatwa / chatgpt-skills / geo-visualizer

geo-visualizer skill

/geo-visualizer

This skill creates interactive geographic maps with markers, heatmaps, routes, and choropleth layers to visualize locations and geographic data.

npx playbooks add skill dkyazzentwatwa/chatgpt-skills --skill geo-visualizer

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
4.6 KB
---
name: geo-visualizer
description: Create interactive maps with markers, heatmaps, routes, and choropleth layers. Use when visualizing geographic data, plotting locations, or creating map-based reports.
---

# Geo Visualizer

Create interactive HTML maps from geographic data using Folium.

## Features

- **Markers**: Plot points with custom icons, popups, and tooltips
- **Heatmaps**: Visualize density/intensity data
- **Choropleth**: Color regions by data values
- **Routes/Lines**: Draw paths between points
- **Circles/Areas**: Show radius-based coverage
- **Layer Control**: Toggle multiple layers
- **Clustering**: Auto-cluster dense markers

## Quick Start

```python
from geo_visualizer import GeoVisualizer

# Simple marker map
viz = GeoVisualizer()
viz.add_markers([
    {"lat": 40.7128, "lon": -74.0060, "name": "New York"},
    {"lat": 34.0522, "lon": -118.2437, "name": "Los Angeles"}
])
viz.save("cities.html")

# From CSV
viz = GeoVisualizer()
viz.from_csv("locations.csv", lat_col="latitude", lon_col="longitude")
viz.save("map.html")
```

## CLI Usage

```bash
# Plot markers from CSV
python geo_visualizer.py --input locations.csv --lat latitude --lon longitude --output map.html

# Add heatmap
python geo_visualizer.py --input data.csv --lat lat --lon lng --heatmap --output heat.html

# With clustering
python geo_visualizer.py --input stores.csv --lat lat --lon lon --cluster --output stores.html

# Choropleth map
python geo_visualizer.py --geojson states.geojson --data stats.csv --key state --value population --output choropleth.html
```

## API Reference

### GeoVisualizer Class

```python
class GeoVisualizer:
    def __init__(self, center=None, zoom=10, tiles="OpenStreetMap")

    # Data loading
    def from_csv(self, filepath, lat_col, lon_col, **kwargs) -> 'GeoVisualizer'
    def from_dataframe(self, df, lat_col, lon_col, **kwargs) -> 'GeoVisualizer'
    def from_geojson(self, filepath) -> 'GeoVisualizer'

    # Markers
    def add_marker(self, lat, lon, popup=None, tooltip=None, icon=None, color="blue")
    def add_markers(self, locations: list, name_col=None, popup_cols=None)
    def cluster_markers(self, enabled=True) -> 'GeoVisualizer'

    # Layers
    def add_heatmap(self, points=None, weight_col=None, radius=15) -> 'GeoVisualizer'
    def add_choropleth(self, geojson, data, key_on, value_col, **kwargs) -> 'GeoVisualizer'
    def add_route(self, points, color="blue", weight=3) -> 'GeoVisualizer'
    def add_circle(self, lat, lon, radius_m, color="blue", fill=True)

    # Output
    def save(self, filepath) -> str
    def get_html(self) -> str
    def fit_bounds(self) -> 'GeoVisualizer'
```

## Marker Options

```python
# Custom icons
viz.add_marker(lat, lon, icon="fa-coffee", color="red")

# With popup content
viz.add_marker(lat, lon, popup="<b>Store #123</b><br>Open 9-5")

# From CSV with popup columns
viz.from_csv("stores.csv", lat_col="lat", lon_col="lon")
viz.add_markers(viz.data, popup_cols=["name", "address", "phone"])
```

## Heatmap Options

```python
# Basic heatmap
viz.add_heatmap()

# Weighted heatmap (e.g., by sales volume)
viz.add_heatmap(weight_col="sales", radius=20, blur=15, max_zoom=12)
```

## Choropleth Maps

```python
# Color regions by data
viz.add_choropleth(
    geojson="us-states.geojson",
    data=state_data,
    key_on="feature.properties.name",  # GeoJSON property
    value_col="population",
    fill_color="YlOrRd",  # Color scale
    legend_name="Population"
)
```

## Tile Layers

Available base maps:
- `OpenStreetMap` (default)
- `CartoDB positron` (light, minimal)
- `CartoDB dark_matter` (dark theme)
- `Stamen Terrain` (terrain features)
- `Stamen Toner` (high contrast B&W)

```python
viz = GeoVisualizer(tiles="CartoDB positron")
```

## Example Workflows

### Store Locator Map
```python
viz = GeoVisualizer()
viz.from_csv("stores.csv", lat_col="lat", lon_col="lon")
viz.add_markers(viz.data, popup_cols=["name", "address", "hours"])
viz.cluster_markers(True)
viz.fit_bounds()
viz.save("store_locator.html")
```

### Sales Heatmap
```python
viz = GeoVisualizer(tiles="CartoDB dark_matter")
viz.from_csv("sales.csv", lat_col="lat", lon_col="lon")
viz.add_heatmap(weight_col="revenue", radius=25)
viz.save("sales_heat.html")
```

### Delivery Route
```python
viz = GeoVisualizer()
stops = [(40.7, -74.0), (40.8, -73.9), (40.75, -73.95)]
viz.add_route(stops, color="blue", weight=4)
for i, (lat, lon) in enumerate(stops):
    viz.add_marker(lat, lon, popup=f"Stop {i+1}")
viz.save("route.html")
```

## Output

- **HTML**: Interactive map viewable in any browser
- **Auto-fit**: Automatically zooms to show all data
- **Responsive**: Works on mobile devices

## Dependencies

- folium>=0.14.0
- pandas>=2.0.0
- branca>=0.6.0

Overview

This skill creates interactive HTML maps from geographic data using Folium. It supports markers, heatmaps, choropleths, routes, circles, clustering, and layer controls for building map-based reports and dashboards.

How this skill works

Load point or polygon data from CSV, DataFrame, or GeoJSON, then add visual layers (markers, heatmap, choropleth, lines, circles) to a Folium map. The API includes convenience methods to cluster markers, weight heatmaps, color regions by data values, and export the result as an HTML file or raw HTML string.

When to use it

  • Visualizing point datasets like stores, incidents, or customer locations
  • Showing density or intensity patterns with heatmaps (sales, calls, events)
  • Creating choropleth maps to compare regions by a metric (population, rates)
  • Plotting delivery routes, service areas, or multi-stop itineraries
  • Generating embeddable interactive maps for reports or web pages

Best practices

  • Clean and validate lat/lon columns before loading to avoid projection errors
  • Use clustering when plotting many close points to improve performance and usability
  • Choose appropriate weight columns and radius for heatmaps to reflect true density
  • Provide concise popup/tooltip content to keep map interactions readable
  • Use fit_bounds after adding data so the initial view shows all features

Example use cases

  • Store locator: load store CSV, add popups with hours, enable clustering, and save store_locator.html
  • Sales heatmap: load transactions, weight by revenue, tune radius and blur, export dark-themed heatmap
  • Choropleth report: load state GeoJSON and a CSV of metrics, map population or rates to a color scale
  • Delivery planning: draw a polyline for stops, add numbered markers with popups for each stop
  • Coverage analysis: add circles around facilities to visualize service area radii

FAQ

What output formats are supported?

Maps export as standalone HTML files and can also be retrieved as HTML strings for embedding.

Can I load data from a pandas DataFrame?

Yes. Use the from_dataframe method specifying latitude and longitude columns.