A Python-based dashboard for ICE detention statistics. This project downloads and renders publically available detention data from the ICE Detention Management page.
This project consists of three Python scripts:
ice_detention_scraper.py
- Downloads ICE detention Excel files and parses the facilities data, outputting a JSON filegeocode_facilities.py
- Geocodes the facilities data using the JSON file from the previous steprender_facilties_map.py
- Simple script that renders a single page static site
- Install using pip
pip install git+https://github.com/lockdown-systems/icewatch.git@main
Download the latest detention statistics (this should auto-find the latest link):
icewatch scrape
Then, extract the data about facilities to a JSON file (you can also do this in one step, see options below):
icewatch scrape --extract-from-file data/YOUR_FILE_HERE.xlsx
The script supports the following options:
--url
: Direct URL to the Excel file (optional, auto-finds by default)--output-dir
: Directory to save the downloaded file (default: data)--verify
: Verify the downloaded file by attempting to read it--no-auto-find
: Disable auto-finding the latest link (use default URL instead)--extract-json
: Extract facilities data to JSON file after downloading--extract-from-file
: Extract facilities data to JSON from an existing Excel file
# Download to a custom directory
icewatch scrape --output-dir ./data
# Download and verify the file
icewatch scrape --verify
# Use a specific URL instead of auto-finding
icewatch scrape --url "https://custom-url.xlsx"
# Download to current directory
icewatch scrape --output-dir .
# Disable auto-find and use default URL
icewatch scrape --no-auto-find
# Download and extract facilities data to JSON
icewatch scrape --extract-json
# Extract JSON from an existing Excel file
icewatch scrape --extract-from-file "path/to/existing/file.xlsx"
You can geocode the facilities in your JSON file using OpenStreetMap Nominatim API. This will add latitude and longitude to each facility and stores address lookups in a cache file to avoid unnecessary API requests. If the OpenStreetMap API doesn't provide a result for a specific facility, you can enter it in the cache file manually once you locate the latitude and longitude.
icewatch geocode --input data/ice_facilities_YYYYMMDD.json
- By default, this will create a new file like
data/facilities_geocoded_YYYYMMDD_HHMMSS.json
and update (or create)data/geocode_cache.json
in the same directory. - You can specify custom output or cache files with
--output
and--cache
. - You can adjust the delay between API requests (default: 2 seconds) with
--delay
.
icewatch geocode --input data/ice_facilities_YYYYMMDD.json --output data/facilities_geocoded_YYYYMMDD.json --cache data/geocode_cache.json
You must set a valid User-Agent string in the script before running it.
Edit the USER_AGENT
variable in geocode_facilities.py
:
USER_AGENT = "icewatch/1.0 ([email protected])"
Replace [email protected]
with your actual email or project contact. This is required by the Nominatim Usage Policy.
You can create a static interactive map of all geocoded facilities using the provided script. The map will show each facility as a marker, with popups displaying the name, address, and rounded counts of criminal and non-criminal detainees.
icewatch render --input data/facilities_geocoded_YYYYMMDD.json
- By default, this will create
docs/index.html
(and thedocs
directory if it doesn't exist). - You can specify a custom output path with
--output
if desired.
This tool is for educational and research purposes. Please ensure compliance with the ICE website's terms of service and respect rate limiting.