Actual location: (-122.27125, 37.80426)
HRSL data: https://registry.opendata.aws/dataforgood-fb-hrsl/
Look around (-122, 38):
gdalwarp -r sum -tr 1 -1 -te -122.5 37.5 -121.5 38.5 \
Actual location: (-122.27125, 37.80426)
HRSL data: https://registry.opendata.aws/dataforgood-fb-hrsl/
Look around (-122, 38):
gdalwarp -r sum -tr 1 -1 -te -122.5 37.5 -121.5 38.5 \
| import numpy as np | |
| from scipy.optimize import root_scalar | |
| from scipy.special import expit # inverse logit | |
| def logit_shift_baseline(df, ndv_col, nrv_col, target=0.5): | |
| ndv = df[ndv_col].values | |
| nrv = df[nrv_col].values | |
| turn = ndv + nrv | |
| # Compute log-odds where turnout > 0 |
| #!/usr/bin/env python3 | |
| """ | |
| Feature finder script to match OSM and Overture features based on tags and spatial proximity. | |
| Usage examples: | |
| feature-finder.py aerodrome airport --name OAK | |
| feature-finder.py national_park --name Alcatraz | |
| """ | |
| from __future__ import annotations |
| #!/usr/bin/env python3 | |
| import itertools | |
| import typing | |
| import math | |
| import cairo | |
| import shapely.affinity | |
| import shapely.geometry | |
| DISTANCE_CUTOFF = 2 # max jump length to bridge with a curve |
| """Convert input CSV to OpenElections CSV | |
| Adapt large tabular sources like this Lenawee County example (1) converted from PDFs (2) | |
| to format required by OpenElections (3) intepreting categories of votes, candidates, and | |
| offices along the way. | |
| 1) https://docs.google.com/spreadsheets/d/1iOEqLFcwuA3J_HXUtEWIZUirA7J1_NdsnVUnc8z0TZY/edit?gid=2129694166#gid=2129694166 | |
| 2) https://github.com/openelections/openelections-sources-mi/blob/master/2024/general/Gogebic%20MI%20Official%20Statement%20of%20Votes%20Cast%20with%20Certification%2011.5.2024.pdf | |
| 3) https://github.com/openelections/openelections-data-mi/issues/69 |
| """Coalesce Excel sheets that appear to be excerpts of larger sheets | |
| Requires pylightxl: https://pylightxl.readthedocs.io/en/latest/ | |
| PDF sources like this Gogebic County example (1) can be converted by AWS Textract | |
| into usable Excel workbooks with multiple sheets (2). This scripts makes a best-effort | |
| attempt to stitch together large tables broken up across multiple pages based on | |
| row counts, column counts, and cell values representing precincts. The results still | |
| require a lot of manual interpretation to be turned into useful OpenElections data (3). |
| import datetime | |
| import math | |
| import mercantile | |
| import pytz | |
| import suncalc | |
| def date(yyyy, mm, dd, hh): | |
| dt_naive = datetime.datetime(yyyy, mm, dd, int(hh), int((60 * hh) % 60)) | |
| dt_local = dt_naive.astimezone(pytz.timezone('America/Los_Angeles')) | |
| dt_utc = dt_local.astimezone(pytz.utc) |
| #!/usr/bin/env python3 | |
| import datetime | |
| import json | |
| import os | |
| import sys | |
| import gzip | |
| import ics | |
| import requests | |
| import pytz |