mggg / maup

The geospatial toolkit for redistricting data.
https://maup.readthedocs.io/en/latest/
MIT License
67 stars 23 forks source link

TypeError raised in `maup.assign` when no targets cover an entire source #51

Closed calebclimatecabinet closed 2 years ago

calebclimatecabinet commented 2 years ago

When calling maup.assign(sources, targets) where no sources are completely covered by a target, we get:

TypeError: Input must be valid geometry objects: 0

Reproducible example:

import geopandas as gpd
from shapely.geometry import Polygon
from shapely.affinity import translate
import maup

# Make a simple grid of 4 1x1 blocks
s1 = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
s2 = Polygon([(1, 0), (1, 1), (2, 1), (2, 0)])
s3 = Polygon([(0, 1), (0, 2), (1, 2), (1, 1)])
s4 = Polygon([(1, 1), (1, 2), (2, 2), (2, 1)])
sources = gpd.GeoSeries([s1, s2, s3, s4])

# Make 4 matching targets that overlap
targets = sources.apply(lambda x: translate(x, xoff=0.1))

# Raises error
maup.assign(sources, targets)

I would expect that the above would return the Series: pd.Series([0, 1, 2, 3])

calebclimatecabinet commented 2 years ago

Seeing now that #48 fixes this. @InnovativeInventor what would it take to merge this PR?

InnovativeInventor commented 2 years ago

Seeing now that #48 fixes this. @InnovativeInventor what would it take to merge this PR?

It's actually ready to merge -- just merged it -- will make a new release with this soon.