Skip to content

dartmouth/CulvertCrawlers-StateData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📍 Two‑Layer Map Project

What it does:
The script reads two CSV files (e.g. a list of schools and a list of hospitals) from a data/ folder, builds an interactive leaflet map with a separate layer for each file, and writes the result to output/map.html.


Table of Contents


Prerequisites

Tool Minimum version
Python 3.8+ (python3 command)
git (optional) any recent version
Unix‑like shell (macOS / Linux) or Windows terminal that supports source (Git Bash, WSL, PowerShell with activation script)

Setup & Installation

# 1️⃣ Create a virtual environment in the project root
python3 -m venv .venv

# 2️⃣ Activate the virtual environment
source .venv/bin/activate        # macOS / Linux
# .venv\Scripts\activate          # Windows PowerShell / CMD

# 3️⃣ Install all required Python packages
pip install -r requirements.txt

After activation your prompt will be prefixed with (.venv), confirming that any python / pip command now runs inside the isolated environment.

Deactivate when you’re done

deactivate

Running the Application

# Ensure the virtual environment is active
source .venv/bin/activate   # (or .venv\Scripts\activate on Windows)

# Run the script
python two_layer_map.py

What happens

  1. The script looks for exactly two CSV files inside the folder data/.
  2. Each CSV must contain the columns latitude, longitude, and a column that will be shown in the popup (by default it looks for a column named name).
  3. Two map layers are created – one for each CSV – and a Leaflet layer control is added so the user can toggle the layers on/off.
  4. The generated interactive map is saved as output/map.html (the output/ directory is created automatically if it does not exist).

Tip:

  • If you want to use a different column for the popup, rename the column to name or edit the script’s NAME_COLUMN constant.
  • The script prints a short summary (rows loaded, output path, etc.) to the console.

CSV Format

Column name Required? Description
latitude Decimal degrees, e.g. 40.7128
longitude Decimal degrees, e.g. -74.0060
name Text shown in the marker popup/tooltip (any other column name can be used by renaming it to name or adjusting the script)
optional Any additional columns are ignored by the script but can be useful for later extensions.

Example (schools.csv)

latitude,longitude,name
40.730610,-73.935242,PS 101
40.712776,-74.005974,PS 102

Place both CSV files in the data/ directory before running the script.


Output

The final artifact is an HTML file that can be opened in any modern web browser:

output/
└── map.html

Open it directly:

open output/map.html      # macOS
xdg-open output/map.html  # Linux
start output\map.html     # Windows

Quick Recap (one‑liner)

python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt && python two_layer_map.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors