mggg / maup

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

Dependency versions #29

Closed frnsys closed 3 years ago

frnsys commented 3 years ago

setup.py doesn't specify any versions for the dependencies. I'm running into a problem that seems to be related to Shapely==1.7.1, in particular with the spatial index (STRtree):

AttributeError: 'MultiPolygon' object has no attribute 'index'

and:

AttributeError: 'Polygon' object has no attribute 'index'

from:

maup/indexed_geometries.py", line 20, in <listcomp>
    relevant_indices = [geom.index for geom in self.spatial_index.query(geometry)]

What version of Shapely should I be using?

Thanks

InnovativeInventor commented 3 years ago

Could you share with us the context in which you're using maup? Did your GeoDataFrame have a .index attribute before maupping?

frnsys commented 3 years ago

Sorry, I forgot to update this. I ended up trying things on a different machine with Shapely==1.6.4 and uninstalling pygeos, which was conflicting with it (I was getting a warning along the lines of "shapely GEOS is incompatible with the GEOS version pygeos was compiled with"). I tried somethings out with Shapely==1.7.1 and as far as I can tell, setting attributes directly on the geometry (e.g. geometry.index) weren't persisting. I'm not sure if that's related specifically to the Shapely version or to the GEOS incompatibility.

InnovativeInventor commented 3 years ago

Ok, could you share a script and/or the shapefile you were using so I can reproduce the issue?

InnovativeInventor commented 3 years ago

Another question about your environment -- are you currently using Windows? The tests pass with Shapely==1.7.1 on Ubuntu and macOS.

frnsys commented 3 years ago

I'm using Ubuntu 20.04. It may be relayed to pygeos rather than Shapely...on another system (Ubuntu 16.04) the issue went away when I uninstalled pygeos.

InnovativeInventor commented 3 years ago

Ok, could you try installing the dependencies using the requirements.txt or pyproject.toml file on master (just merged it in)?

pip install -r requirements.txt
frnsys commented 3 years ago

Just gave it a try--looks like it's working without any issues! Thank you

spencer-rdh commented 8 months ago

I'm having this issue as well and just conda installed maup directly.