Overview

β¨ Features¶
- π Geocoding β Convert free-form addresses or city, state, and country triples into coordinates.
- π§ Places Fallback β Use Places text search when geocoding does not resolve a location.
- π Distance Matrix β Compute distance and travel time between origins and destinations.
- πΊοΈ Interactive Maps β Render uploaded or geocoded coordinate data with map overlays.
- πΌοΈ Static Maps β Generate static map previews and map image URLs for reporting.
- β±οΈ Time Zones β Resolve IANA time zones from latitude and longitude.
- π Excel and CSV Enrichment β Upload spreadsheets and enrich records with geocoded coordinates.
- ποΈ SQLite Data Management β Browse, insert, update, delete, geocode, profile, and query local tables.
- π¦οΈ Weather Data β Query Google Weather, OpenWeather/Open-Meteo, historical weather, climate data, and tides/current data.
- π«οΈ Environmental Data β Query air quality, UV index, EPA EnviroFacts, PurpleAir, NASA FIRMS, and NASA EONET data.
- π Astronomical Data β Access naval observatory, space weather, star chart, satellite, catalog, AstroQuery/SIMBAD, and star map functionality.
- π Geological Data β Query USGS earthquakes, water data, national map data, and global imagery.
- πΈοΈ Web Scraper β Fetch, crawl, parse, summarize, and extract structured data from web pages.
- β‘ Rate Limiting and Caching β Control API usage with QPS limits and optional cache backends.
- π οΈ Explicit Error Handling β Use clear exception paths for not-found, gateway, and framework errors.
π§ Application Modes¶
The Streamlit application is organized around the following modes.
| Mode | Purpose | Primary Outputs |
|---|---|---|
| Geocoding | Resolve addresses or city/state/country records into latitude and longitude. | Coordinates, formatted address, geocoded map records. |
| Interactive Map | Display coordinate-based records on an interactive map. | Map overlay, geocoded record preview. |
| Distances | Calculate travel distance and estimated travel time between origin and destination. | Distance text, duration text, raw response. |
| Static Maps | Generate a static map URL centered on selected coordinates. | Static map preview/link. |
| Time Zones | Look up a time zone from coordinates and timestamp context. | Time-zone identifier and raw lookup response. |
| Web Scraper | Fetch or crawl web content and extract text, links, metadata, and structured content. | Summary, text, HTML, structured data, crawl JSON. |
| Weather | Query weather, historical weather, climate, and tides/current data. | Weather tables, summaries, and raw API responses. |
| Environmental | Query air quality, UV, sensor, facility, fire, and natural event data. | Environmental dataframes, summaries, raw results. |
| Astronomical | Query astronomy, satellite, space weather, star chart, and star map services. | Astronomical dataframes, generated links, raw results. |
| Celestial Map | Render a sky/celestial map from the active location. | Celestial map visualization. |
| Geological | Query earthquake, water, imagery, and national map services. | Geological result tables, imagery, raw results. |
| Data Upload | Load Excel or CSV files into the application session. | Working dataframe and preview. |
| Data Management | Manage SQLite tables, geocode missing report coordinates, inspect schema, and run SQL. | Updated tables, coordinate updates, schema views, query results. |
π§© Streamlit Sidebar¶
The application sidebar provides the main operating controls:
| Section | Purpose |
|---|---|
| π°οΈ GIS Mapping | Select the active application mode. |
| ποΈ Configuration | Configure location, browser geolocation, API keys, and application settings. |
| ποΈ Data | Load, inspect, and manage data sources used by the current mode. |
| π Credentials | Provide API keys for Google, Google Maps, Geocoding, NASA, AirNow, OpenAQ, FIRMS, PurpleAir, and related services. |
π¦ Installation¶
Clone the repository and install dependencies.
git clone https://github.com/is-leeroy-jenkins/Mappy.git
cd Mappy
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
For Linux or macOS:
git clone https://github.com/is-leeroy-jenkins/Mappy.git
cd Mappy
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
π Configuration¶
mappy can read configuration values from config.py, Streamlit session state, or environment
variables depending on how the application is deployed.
Common keys include:
| Key | Purpose |
|---|---|
GOOGLE_API_KEY |
General Google API access. |
GOOGLE_CSE_ID |
Google Custom Search Engine identifier. |
GOOGLEMAPS_API_KEY |
Google Maps API access. |
GEOCODING_API_KEY |
Geocoding API access. |
GOOGLE_CLOUD_PROJECT_ID |
Google Cloud project identifier. |
GOOGLE_CLOUD_LOCATION |
Google Cloud location/region. |
GOOGLE_WEATHER_API_KEY |
Google Weather API access. |
GOVINFO_API_KEY |
GovInfo API access. |
NASA_API_KEY |
NASA API access. |
NASA_EARTHDATA_TOKEN |
NASA Earthdata token. |
AIRNOW_API_KEY |
AirNow API access. |
OPENAQ_API_KEY |
OpenAQ API access. |
FIRMS_MAP_KEY |
NASA FIRMS map key. |
OPENSKY_API_CLIENT_ID |
OpenSky client identifier. |
OPENSKY_API_CREDENTIALS |
OpenSky credential payload. |
PURPLEAIR_API_KEY |
PurpleAir API access. |
π Running the Streamlit App¶
Start the application from the repository root.
The app uses a wide layout and opens with the sidebar expanded. Select a mode from **π°οΈ GIS Mapping ** and then configure the relevant location, credentials, and data inputs from the sidebar and mode-specific expanders.
π Quick Start: Python Framework¶
1. Initialize Maps¶
2. Geocode an address¶
from mappy import Geocoder
geo = Geocoder( maps )
result = geo.freeform( "Paris, France" )
print( result[ "lat" ], result[ "lng" ], result[ "formatted_address" ] )
3. Calculate distance¶
from mappy import DistanceMatrix
dist = DistanceMatrix( maps )
distance = dist.summary( "New York, USA", "Los Angeles, USA", mode="driving" )
print( distance[ "distance_text" ], distance[ "duration_text" ] )
4. Get a static map URL¶
from mappy import StaticMapURL
static_map = StaticMapURL( api_key="YOUR_API_KEY" )
url = static_map.pin( lat=48.8584, lng=2.2945, zoom=14 )
print( url )
5. Process Excel locations¶
from mappy import Excel
excel = Excel( api_key="YOUR_API_KEY" )
excel.enrich(
input_path="locations.xlsx",
output_path="locations_with_coords.xlsx",
city_col="City",
state_col="State",
country_col="Country"
)
ποΈ Data Management¶
The application includes a SQLite management mode for local data workflows. It can:
- Preview the current table.
- Insert rows.
- Update rows.
- Delete rows.
- Profile table data.
- Drop selected tables.
- Create custom tables.
- Inspect table columns and indexes.
- Run SQL through the SQL console.
- Locate report rows missing coordinates.
- Geocode missing report coordinates and write latitude/longitude values back to the database.
This mode is especially useful for datasets with columns similar to:
| Column | Purpose |
|---|---|
ID |
Primary record identifier. |
Year, Month, Day |
Date components. |
CalendarDate |
Full date value. |
City, State, Country |
Location fields used for geocoding. |
Latitude, Longitude |
Coordinate outputs. |
Shape |
Optional observation or object shape classification. |
Summary |
Free-text record description. |
π Project Structure¶
mappy/
βββ app.py # Streamlit application
βββ config.py # Application constants, paths, keys, and modes
βββ maps.py # Maps API gateway
βββ geocode.py # Address and location geocoding
βββ places.py # Places text-search fallback
βββ distances.py # Distance Matrix support
βββ timezones.py # Time-zone resolution
βββ staticmaps.py # Static map URL generation
βββ excel.py # Excel and CSV integration helpers
βββ caches.py # In-memory and SQLite cache backends
βββ fetchers.py # Weather, environmental, astronomical, geological, and web fetchers
βββ exceptions.py # Custom framework exceptions
βββ requirements.txt # Python dependencies
βββ resources/ # Images, setup documentation, and supporting assets
β οΈ Error Handling¶
- NotFound β Raised when a location cannot be resolved.
- GatewayError β Raised when HTTP or API communication fails.
- MappyError β Base class for framework-level exceptions.
By catching these explicitly, bulk geocoding, file enrichment, and API-backed workflows can fail cleanly without losing the rest of the processing run.
π‘ Design Philosophy¶
- Simplicity first β Each framework class has a single clear responsibility.
- Composable services β Geocoding, distance, maps, time zones, cache, and fetcher services can be used alone or together.
- Streamlit-first operations β The app exposes common workflows through mode-specific controls rather than forcing command-line use.
- Cache-friendly design β Optional in-memory and SQLite cache support reduces repeated API calls.
- Rate-aware calls β QPS controls help protect API quotas.
- Spreadsheet-ready workflows β Excel and CSV support is built into the application.
- Data-management capable β SQLite tooling supports local enrichment, auditing, and iterative cleanup.
π§ͺ Example Use Cases¶
- Enriching customer, facility, incident, or report datasets with GPS coordinates.
- Calculating travel distances for relocation, service coverage, logistics, or routing analysis.
- Creating static map thumbnails for reports, dashboards, or case summaries.
- Validating and normalizing international addresses.
- Auditing time-zone coverage for scheduling or distributed operations.
- Mapping weather, environmental, geological, or astronomical data around a selected location.
- Updating local SQLite tables with missing latitude and longitude values.
- Scraping web pages into structured text, links, and metadata for downstream analysis.
π API Key References¶
AI API Keys¶
Data Services¶
| Service | Link | Service | Link |
|---|---|---|---|
| Claude | API Keys | Mistral | Console |
| NASA | NASA API | Geolocation | Google Geolocation |
| Google Maps | Google Maps | GovInfo | GovInfo API |
| The News API | Register | Google Weather | Weather API |
| Grokipedia | PyPI | CDC | CDC Data |
| PurpleAir | Developer Portal | FIRMS | NASA FIRMS |
| Census | API Key | Wikipedia | Wikimedia APIs |
π Dependencies¶
Core dependencies include:
| Dependency | Purpose |
|---|---|
streamlit |
Application framework. |
streamlit-js-eval |
Browser geolocation support. |
pandas |
Tabular data processing. |
openpyxl |
Excel workbook I/O. |
requests |
HTTP client support. |
beautifulsoup4 |
HTML parsing. |
plotly |
Interactive charts. |
pydeck |
Map rendering. |
matplotlib |
Supporting visualization backend. |
sqlite3 |
Local database access through the Python standard library. |
Additional dependencies may be required by optional fetchers or provider-specific workflows.