This Marimo notebook calculates how many 1-mile radius circles are needed to cover the entire United Kingdom, saves the circle center points to a SQLite database, and visualizes them on an interactive map.
- Fetches actual UK boundary data from GeoJSON sources
- Calculates optimal grid spacing using hexagonal-like packing (�3 × radius H 1.732 miles)
- Filters points to only include those within UK boundaries
- Stores all circle center coordinates (latitude/longitude) in SQLite database
- Visualizes coverage on an interactive Folium map
- Shows detailed statistics about coverage
- Ensure you have Python 3.13+ and
uvpackage manager installed - Install dependencies:
uv syncRun the Marimo notebook:
uv run marimo edit main.pyThis will open the notebook in your browser where you can:
- See the step-by-step calculation process
- View the total number of circles needed
- Explore the interactive map visualization
- Access the database with all circle centers
The circle center points are saved to uk_coverage.db with the following schema:
CREATE TABLE circle_centers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
latitude REAL NOT NULL,
longitude REAL NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)You can query the database using Python:
import sqlite3
conn = sqlite3.connect('uk_coverage.db')
cursor = conn.cursor()
# Get all circle centers
cursor.execute("SELECT latitude, longitude FROM circle_centers")
points = cursor.fetchall()
print(f"Total circles: {len(points)}")
conn.close()- UK Boundary: Fetches actual UK administrative boundaries from GeoJSON data
- Grid Generation: Creates a hexagonal-like grid with 1.732-mile spacing between centers
- Filtering: Only keeps points that fall within UK boundaries
- Database Storage: Saves all valid circle centers to SQLite
- Visualization: Displays a sample of circles on an interactive map (showing 500 circles to avoid performance issues)
To change the circle radius or coverage area, modify these variables in main.py:
radius_miles: Change the circle radius (line 81)spacing_miles: Adjust grid spacing for different coverage patterns (line 82)- UK boundary URL can be changed in the
get_uk_boundary()function (line 43)
- Uses hexagonal-like packing with spacing = radius × �3 for optimal coverage
- Coordinates are in WGS84 (EPSG:4326) decimal degrees
- Distance calculations account for Earth's curvature at UK latitude (~55°N)
- Map visualization samples 500 circles for performance (all points are in database)