parkingstudy

Parking occupancy and turnover survey analysis: inventory, occupancy by beat, effective capacity, licence-plate turnover and overstay with salted hashing, heatmaps and demand-responsive pricing.

Version 0.1.3 · Python >=3.9 · MIT licence
pip install parkingstudy
PyPISourceIssuesChangelogCite (DOI)

parkingstudy

PyPI version Python versions pipeline status License: MIT DOI Downloads

Parking occupancy and turnover survey analysis for planners.

parkingstudy turns the spreadsheets of a classic parking study into the numbers a parking management plan needs:

Standard library only, no required dependencies. Requires Python 3.9 or newer.

pip install parkingstudy

Quick start (command line)

Input files are plain CSV (column names are case-insensitive):

file required columns optional columns
inventory block_face_id, spaces zone, space_type, facility (on_street/off_street), time_limit_min, restriction, unavailable (07:00-09:00;16:00-18:00), hourly_rate
counts block_face_id, beat, occupied space_type, date
sightings block_face_id, beat, and plate_token or plate space_type, date

beat is a clock time (08:30) or an ISO date-time (2026-03-10T08:30).

# 1. Create a secret salt once per survey, keep it out of version control
parkingstudy salt > survey.salt
export PARKINGSTUDY_SALT=$(cat survey.salt)

# 2. Anonymise the field sheets: the plate column is replaced by a token column
parkingstudy hash-plates sightings_raw.csv -o sightings.csv

# 3. Supply summary, occupancy by beat and peak vs. 85 % effective capacity
parkingstudy inventory inventory.csv
parkingstudy occupancy inventory.csv counts.csv --by zone -o occupancy.csv
parkingstudy occupancy inventory.csv counts.csv --by zone --peak --target 0.85 \
    --factor on_street=0.85 --factor off_street=0.90
parkingstudy occupancy inventory.csv counts.csv --by zone --space-hours

# 4. Turnover, duration and overstay from the plate survey
parkingstudy turnover inventory.csv sightings.csv --by block_face --beat-minutes 30 \
    --stays stays.csv -o turnover.csv
parkingstudy turnover inventory.csv sightings.csv --durations      # duration classes

# 5. Heatmap (zone x hour) and pricing recommendations for the 09:00-12:00 rate period
parkingstudy heatmap inventory.csv counts.csv --by zone --bin-minutes 60 -o heatmap.csv
parkingstudy pricing inventory.csv counts.csv --from 09:00 --to 12:00 --policy sfmta

# 6. Map it: join any result CSV (key column) to block-face GeoJSON
parkingstudy geojson block_faces.geojson turnover.csv -o turnover_map.geojson

Every analysis command writes CSV (or --format json) to standard output or -o FILE. turnover also accepts raw plates directly if a salt is supplied (--salt-env VAR or --salt-file FILE); without one it refuses to read them.

Quick start (Python)

from parkingstudy import (
    PlateHasher, read_inventory, read_counts, read_sightings,
    capacity_assessment, build_stays, turnover_summary, utilization_heatmap,
)

inv = read_inventory("inventory.csv")
counts = read_counts("counts.csv")

for row in capacity_assessment(inv, counts, by="zone", target=0.85):
    print(row.key, row.peak_occupied, row.spaces, row.effective_capacity, row.above_target)

hasher = PlateHasher.from_env()            # salt from $PARKINGSTUDY_SALT
sightings = read_sightings("sightings_raw.csv", hasher)   # plates hashed while reading
stays = build_stays(sightings, beat_minutes=30, inventory=inv)
for r in turnover_summary(stays, inv, by="block_face"):
    print(r.key, r.turnover, r.mean_duration_min, r.overstay_share)

print(utilization_heatmap(inv, counts, by="zone").to_csv())

See examples/quickstart.py for a complete synthetic survey.

API overview

area objects
inventory InventoryRecord, Inventory (capacity, time_limit, hourly_rate, summary)
occupancy Count, occupancy_by_beat, peak_occupancy, effective_capacity, practical_capacity, capacity_assessment, accumulation_curve, space_hours, infer_beat_minutes
plate survey Sighting, build_stays, Stay, turnover_summary, TurnoverRow, accumulation_from_stays, duration_distribution
heatmap utilization_heatmap, HeatmapTable (get, max_cell, to_rows, to_csv)
pricing PricingPolicy, PriceBand, SFMTA_POLICY, SFPARK_PILOT_POLICY, recommend_rate, recommend_rates, mean_occupancy
GeoJSON join_to_geojson, rows_by_key, load_geojson, write_geojson
privacy PlateHasher, generate_salt, normalize_plate, anonymise_rows, anonymise_csv
I/O read_inventory, read_counts, read_sightings, write_rows, records_to_rows

Aggregation everywhere uses by="block_face" | "zone" | "total".

Method and sources

Occupancy. Occupancy rate at a beat = vehicles / legal spaces available at that beat. Spaces inside an unavailable window count as zero supply; vehicles parked there are still counted, so rates above 100 % (illegal parking) are kept and flagged (over_capacity). Zone and total rates sum vehicles and spaces of the block faces counted at that beat.

Effective capacity = spaces x target occupancy. The 85 % default is the "85 percent rule" for kerb parking advocated by D. Shoup, The High Cost of Free Parking (APA Planners Press, 2005): above roughly 85 % occupancy drivers start cruising for a space. Practical capacity (also "effective supply") multiplies spaces by an efficiency factor per facility type. The defaults (0.85 on-street, 0.90 off-street) are common planning rules of thumb rather than values from a standard; pass your own factors= / --factor.

Licence-plate beat survey. A vehicle seen on consecutive beats at the same block face (or zone, level="zone") is one stay. With beat length b, first and last sightings t1 and tn: minimum duration = tn - t1; estimated duration = tn - t1 + b (each sighting stands for one beat, the usual beat-survey convention). The true duration lies between tn - t1 and tn - t1 + 2b. Stays on the first or last beat of a survey session are flagged as censored. max_gap_beats tolerates missed reads. Turnover = vehicles / spaces over the survey period (and per hour). Space-hours of demand = sum of estimated durations; utilization = space-hours / (spaces x survey hours). Overstay compares a stay with the posted limit of its block face: the default basis="minimum" counts only stays certainly longer than the limit (enforcement-grade, conservative); basis="estimate" uses the estimated duration.

Pricing. SFMTA_POLICY follows SFMTA, Demand-responsive parking pricing policies: on-street parking meters and off-street lots (5 December 2017): occupancy 80 % or above raises the hourly rate by 0.25, 60 % to below 80 % leaves it unchanged, below 60 % lowers it by 0.25, within 0.50 to 8.00 per hour. SFPARK_PILOT_POLICY is the four-band table reported for the 2011-2013 SFpark pilot (80-100 % +0.25, 60-80 % hold, 30-60 % -0.25, below 30 % -0.50, cap 6.00). Both are configurable examples: build a PricingPolicy with your own bands, steps, currency, floor, cap and rounding.

Plate anonymisation. Plates are normalised (Unicode NFKC, upper case, letters and digits only) and replaced by HMAC-SHA256 (RFC 2104) keyed with a secret salt of at least 16 bytes, truncated to 16 hex characters by default. Unlike an unsalted hash, tokens cannot be reversed by enumerating the small space of valid plates without the salt. Use a fresh salt per survey and destroy it afterwards. Licence plates are personal data under, for example, the EU GDPR and the Turkish KVKK (Law No. 6698); check the rules that apply to your survey.

Limitations

Development

pip install -e ".[dev]"
python -m pytest
python -m ruff check . && python -m ruff format --check src tests
python -m mypy src

Related Geophilo SDKs

License

MIT License, see LICENSE.

Academic citation

If you use parkingstudy in research, please cite:

@software{eminoglu_parkingstudy,
  author  = {Eminoğlu, Yusuf},
  title   = {parkingstudy},
  year    = {2026},
  version = {0.1.3},
  doi     = {10.5281/zenodo.24235602},
  url     = {https://gitlab.com/geophilo1/parkingstudy_sdk}
}

Other Geophilo SDKs