{"id":23291036,"url":"https://github.com/jplusplus/overlap","last_synced_at":"2025-07-29T19:14:09.649Z","repository":{"id":29577426,"uuid":"33117084","full_name":"jplusplus/overlap","owner":"jplusplus","description":"Extrapolate data from one set of administrative entities to another","archived":false,"fork":false,"pushed_at":"2015-03-30T10:48:06.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-14T04:55:28.500Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jplusplus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-30T10:35:46.000Z","updated_at":"2016-01-25T07:35:04.000Z","dependencies_parsed_at":"2022-09-03T11:31:02.482Z","dependency_job_id":null,"html_url":"https://github.com/jplusplus/overlap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jplusplus/overlap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jplusplus%2Foverlap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jplusplus%2Foverlap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jplusplus%2Foverlap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jplusplus%2Foverlap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jplusplus","download_url":"https://codeload.github.com/jplusplus/overlap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jplusplus%2Foverlap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267740377,"owners_count":24137084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-20T05:13:55.160Z","updated_at":"2025-07-29T19:14:09.625Z","avatar_url":"https://github.com/jplusplus.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"The problem\n-----------\nYou have two different, overlapping administrative divisions, and want statistics based on one of them extrapolated to the other.\n\nCase: We have hardly any demographic data for the 15,000 or so Swedish postal codes. On the other hand we have plenty of interesting data on the ≈ 6,000 electorial districts. Given a fairly large dataset where we know the postal codes, we can extrapolate statistics from electorial districts, and get a fair approximation.\n\nThe solution\n------------\nUse your favourite GIS software to intersect the two administrative systems. Create a .dfb (QGIS) or .csv file containing an area column for the intersections. Run the file through `create_factors.py`, to create a table of weighing factors. Then run your statistics through `run_stats.py` to apply.\n\nThis will obviously create useful results only for fairly small and homogenous administrative entities, and fairly large datasets. Common sense is your friend here.\n\nExample\n-------\nWe have two administrative systems: *Counties* and *provinces*. We know the number of camels in each *province*:\n\n     province, num_camels\n     Värmland, 12\n     Dalarna, 20\n\nNow we want to know the approximate number of camels in each *county*.\n\n1. Using QGIS, we produce a .dbf file with all intersections:\n\n     `ID | county          | province   | area`  \n     `1  | Värmlands län   | Värmland   | 190`  \n     `2  | Värmlands län   | Dalarna    | 6`  \n     `3  | Dalarnas län    | Dalarna    | 180`  \n\n2. Then we run `weighted_data --id_1=county --id_2=province --area=area` to produce a json file, `factors.json`, with weighing factors:\n\n     `\"Värmlands län\": {\"Värmland\": 1, \"Dalarna\": .03},`  \n     `\"Dalarnas län\": {\"Dalarna\": .97}`\n\n3. Finally, we run our camel data through this filter, `run_stats --id=province --value=num_camels --factors=factors.json --input=input.csv`, to get the approximate count of camels in each county:\n\n    `Värmlands län, 12.6`  \n    `Dalarnas län, 19.4`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjplusplus%2Foverlap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjplusplus%2Foverlap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjplusplus%2Foverlap/lists"}