Revival 3/4: study areas from OpenStreetMap and a synthetic crime generator - #4
Merged
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #3.
crime_mapping.load_study_area("Natal, Rio Grande do Norte, Brazil")geocodes a place withosmnxand returns its boundary polygon ready forDataset/create_grid*;osmnxis an optional extra (predspot[osm]); a point result raises a clear error suggesting a more specific querypredspot.syntheticmodule: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 withseed, can return the hotspot centrespipeline.generate_testdatanow delegates to the generatorPREDSPOT_NETWORK_TESTS=1🤖 Generated with Claude Code
https://claude.ai/code/session_01FtZdc2gGrDh4PGSLyT9yRE