Skip to content

Revival 3/4: study areas from OpenStreetMap and a synthetic crime generator - #4

Merged
adaj merged 1 commit into
revival/02-packagingfrom
revival/03-spatiotemporal
Sep 14, 2026
Merged

adaj merged 1 commit into
revival/02-packagingfrom
revival/03-spatiotemporal

Conversation

@adaj

@adaj adaj commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #3.

  • crime_mapping.load_study_area("Natal, Rio Grande do Norte, Brazil") geocodes a place with osmnx and returns its boundary polygon ready for Dataset / create_grid*; osmnx is an optional extra (predspot[osm]); a point result raises a clear error suggesting a more specific query
  • New predspot.synthetic module: generate_crimes(study_area, n_events, start, end, n_hotspots, hotspot_share, hotspot_sd_km, tags, trend, annual_amplitude, annual_peak_month, weekly_profile, hourly_profile, seed, return_hotspots) — Gaussian hotspots + uniform background in space; linear trend, annual cycle, day-of-week and hour-of-day profiles in time, sampled by thinning (exact for a fixed number of events). Works with any polygon/CRS, reproducible with seed, can return the hotspot centres
  • pipeline.generate_testdata now delegates to the generator
  • Tests: 57 total; osmnx is mocked, and an opt-in real query runs with PREDSPOT_NETWORK_TESTS=1

🤖 Generated with Claude Code

https://claude.ai/code/session_01FtZdc2gGrDh4PGSLyT9yRE

- crime_mapping.load_study_area("City, State, Country") geocodes a place
  with osmnx and returns its boundary polygon as a GeoDataFrame ready for
  Dataset / the create_grid* functions; osmnx is an optional extra
  (`predspot[osm]`), points instead of polygons raise a clear error
- New predspot.synthetic module: generate_crimes(study_area, ...) draws
  events from a Gaussian-hotspot + uniform-background spatial mixture and an
  inhomogeneous temporal intensity (linear trend, annual cycle, day-of-week
  and hour-of-day profiles) sampled by thinning; works with any study area
  polygon in any CRS; reproducible with `seed`; can return hotspot centres
- pipeline.generate_testdata now delegates to the synthetic generator
- Tests for both features (osmnx mocked; an opt-in network test is run with
  PREDSPOT_NETWORK_TESTS=1); README/CHANGELOG/CONTRIBUTING updated

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FtZdc2gGrDh4PGSLyT9yRE
@adaj
adaj merged commit 2fc0bef into revival/02-packaging Sep 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant