wanted to add a cell to the raspberry pi e-paper dashboard that shows which US states i've been to based on photo location data. the initial thought was to use the travel planner API or manually maintain a list, but the travel planner only tracks country-level atlas stats, not state-level granularity. immich has all the GPS metadata from photos already so the plan was to pull that directly.
v3 of immich just dropped with workflows but they're UI-based drag-and-drop tools with no API access for external queries, so workflows wouldn't help here. the cleanest approach ended up being querying the immich postgresql database directly for the asset_exif table which has latitude, longitude, state, and city fields. that bypasses pagination issues with the REST API and gives all location-tagged photos in one shot.
using geopandas to load a US states geojson file, then mapping photo counts per state onto state polygons. darkest shades for states with over a thousand photos, medium density for two hundred to a thousand, light for under two hundred, and very light gray or ignored for under ten photos to filter out flight-over noise. the map renders as grayscale polygons on a PIL canvas with correct aspect ratio preservation so it doesn't stretch or squash.
the dashboard function calls the database query, builds a dictionary of state to photo count, maps each state polygon to a grayscale value based on density, then draws the result onto the e-paper canvas. runs daily via cron so the map updates automatically as new photos upload with GPS metadata. the function is available in the canvas editor as a cell type so it sits alongside other dashboard elements like home assistant sensor states and camera feeds.