Closed gabeschoenbach closed 3 years ago
Using the latest version of maup (version 1.0.1), disaggregating CVAP data from block groups down to blocks gives strange behavior.
maup
1.0.1
import geopandas as gpd import maup import math bgs = gpd.read_file("bgs.shp") blocks = gpd.read_file("blocks.shp")
Even though these shapefiles came from the Census, there are a couple geometry errors that need to be fixed:
blocks[blocks["geometry"].apply(lambda x: isinstance(x, (Polygon, MultiPolygon)))] bgs["geometry"] = maup.close_gaps(bgs)
Cropping and dropping empty geometries (per @InnovativeInventor and @amybecker's suggestions) doesn't change anything — in this case there aren't any empty geometries:
blocks["geometry"] = maup.crop_to(blocks, bgs) bgs["geometry"] = maup.crop_to(bgs, blocks) blocks = blocks[~blocks["geometry"].is_empty] bgs = bgs[~bgs["geometry"].is_empty]
After doing this, the area of the symmetric difference between these two regions is 0:
print(blocks.unary_union.symmetric_difference(bgs.unary_union).area)
Disaggregating CVAP from bgs -> blocks:
cvap_cols = ["CVAP", "WCVAP", "BCVAP", "HCVAP", "ASIANCVAP"] assignment = maup.assign(blocks, bgs) weights = blocks["VAP"] / assignment.map(bgs["VAP"]) prorated = maup.prorate(assignment, bgs[cvap_cols], weights) blocks[cvap_cols] = prorated
The issue is that the following should be True, but it isn't:
True
math.isclose(blocks["CVAP"].sum(), bgs["CVAP"].sum())
Fixed by #34
Using the latest version of
maup
(version1.0.1
), disaggregating CVAP data from block groups down to blocks gives strange behavior.Even though these shapefiles came from the Census, there are a couple geometry errors that need to be fixed:
Cropping and dropping empty geometries (per @InnovativeInventor and @amybecker's suggestions) doesn't change anything — in this case there aren't any empty geometries:
After doing this, the area of the symmetric difference between these two regions is 0:
Disaggregating CVAP from bgs -> blocks:
The issue is that the following should be
True
, but it isn't: