Modern GIS toolkit for Python - Simplifying geospatial workflows with built-in data sources, intelligent caching, and fluent APIs
Get up and running with PyMapGIS in just 5 minutes! This guide will walk you through installation, basic usage, and your first interactive map.
pip install pymapgis
git clone https://github.com/pymapgis/core.git
cd core
poetry install
Letβs create an interactive map showing housing cost burden across US counties:
import pymapgis as pmg
# Load Census data with automatic geometry
data = pmg.read("census://acs/acs5?year=2022&geography=county&variables=B25070_010E,B25070_001E")
# Calculate housing cost burden (30%+ of income on housing)
data["cost_burden_rate"] = data["B25070_010E"] / data["B25070_001E"]
# Create interactive map
data.plot.choropleth(
column="cost_burden_rate",
title="Housing Cost Burden by County (2022)",
cmap="Reds",
legend=True
).show()
Thatβs it! You just created an interactive map with real Census data in 6 lines of code.
pmg.read()
- Automatically fetched Census ACS data and county boundaries.plot.choropleth()
- Generated an interactive Leaflet map.show()
- Displayed the map in your browserdata.plot.choropleth(
column="cost_burden_rate",
title="Housing Cost Burden by County",
cmap="viridis", # Try: 'Blues', 'Reds', 'plasma', 'coolwarm'
legend=True,
legend_kwds={'caption': 'Burden Rate'},
style_kwds={'fillOpacity': 0.7, 'weight': 0.5}
).show()
data.plot.choropleth(
column="cost_burden_rate",
tooltip=['NAME', 'cost_burden_rate'],
popup=['NAME', 'B25070_010E', 'B25070_001E'],
title="Interactive Housing Cost Map"
).show()
# Get labor force data
labor = pmg.read("census://acs/acs5?year=2022&geography=county&variables=B23025_004E,B23025_003E")
labor["lfp_rate"] = labor["B23025_004E"] / labor["B23025_003E"]
labor.plot.choropleth(column="lfp_rate", title="Labor Force Participation").show()
# Get just county boundaries
counties = pmg.read("tiger://county?year=2022&state=06") # California counties
counties.plot.interactive().show()
# Load your own geospatial data
my_data = pmg.read("file://path/to/your/data.geojson")
my_data.plot.interactive().show()
import pymapgis as pmg
# Configure cache TTL (time-to-live)
pmg.settings.cache_ttl = "24h" # Cache for 24 hours
pmg.settings.cache_ttl = "90m" # Cache for 90 minutes
# Disable caching (not recommended)
pmg.settings.disable_cache = True
# Set default Census API year
pmg.settings.census_year = 2021
# Configure request timeout
pmg.settings.request_timeout = 30 # seconds
Now that youβve created your first map, explore more advanced features:
Try these challenges to explore PyMapGIS further:
Happy mapping! πΊοΈβ¨