Skip to main content

Redistribute values between geographies (direct area-weighted and parcel-weighted)

Project description

sdc-redistribute

Redistribute values between geographies — direct area-weighted interpolation and parcel-weighted redistribution.

Part of the Social Data Commons toolkit. Extracted from sdc_core.redistribute; used by SDC pipelines to move measures from one geographic vintage/level onto another (e.g. 2010 tracts → 2020 block groups), producing _geo10/_geo20-suffixed measures.

Install

uv add sdc-redistribute   # or: pip install sdc-redistribute

Quickstart

Split a tract's count onto two equal-area block groups (geometries generated inline so the example is self-contained):

import tempfile, pathlib
import geopandas as gpd
import pandas as pd
from shapely.geometry import box
from sdc_redistribute import redistribute_direct

tmp = pathlib.Path(tempfile.mkdtemp())
gpd.GeoDataFrame({"geoid": ["T1"]}, geometry=[box(0, 0, 2, 2)], crs="EPSG:4326").to_file(tmp / "tract.geojson", driver="GeoJSON")
gpd.GeoDataFrame({"geoid": ["BG1", "BG2"]}, geometry=[box(0, 0, 1, 2), box(1, 0, 2, 2)], crs="EPSG:4326").to_file(tmp / "bg.geojson", driver="GeoJSON")

source_df = pd.DataFrame({"geoid": ["T1"], "year": [2020], "measure": ["pop"], "value": [100.0]})
out = redistribute_direct(source_df, source_geo=tmp / "tract.geojson",
                          target_geos={"block_group": tmp / "bg.geojson"}, count_cols=["pop"])
print(out[["geoid", "measure", "value"]].to_string(index=False))
#  geoid    measure  value
#    BG1 pop_direct   50.0
#    BG2 pop_direct   50.0

Public API

  • redistribute_direct — area-proportional redistribution between two geographies.
  • redistribute_parcels — parcel-centroid-weighted redistribution.
  • run_redistribution — high-level wrapper driven by a pipeline.yaml config block.

Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdc_redistribute-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdc_redistribute-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file sdc_redistribute-0.1.1.tar.gz.

File metadata

  • Download URL: sdc_redistribute-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sdc_redistribute-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a87e2f99bedac121bd93f8161b20ddc4843f82a1fa8e7f3a436bd113c9f165eb
MD5 dd9435b0be69e0d3aded223c5ef0dd6d
BLAKE2b-256 27620f535185b84e1b463eeaea99b124bfc2c997ea1face197c89b535ac124c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdc_redistribute-0.1.1.tar.gz:

Publisher: publish-redistribute.yml on dads2busy/Social-Data-Commons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sdc_redistribute-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sdc_redistribute-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8184d4e3fbbbc126c82d24ac00f3946c7bf67842b2bd37f9171e5de00c5185e1
MD5 ae7efd27a4b4acc10a728a2f0f7244ed
BLAKE2b-256 3533d05d2e16487046ab6b38c2df5ec43a137d3ecb32055e21c0b91f7e1d1c42

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdc_redistribute-0.1.1-py3-none-any.whl:

Publisher: publish-redistribute.yml on dads2busy/Social-Data-Commons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page