Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering an "unhashable type" error Momepy.preprocess function #482

Open
matthewhiett opened this issue Apr 18, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@matthewhiett
Copy link

Describe the problem

momepy.preprocess returns TypeError: unhashable type: 'list'.

Both Momepy and GeoPandas are the most recent versions (see below). I also checked to make sure that I am passing a GeoDataFrame which returns <class 'geopandas.geodataframe.GeoDataFrame'>.

image

Steps to reproduce

import momepy
import geopandas as gpd
import osmnx as ox

#Get building geometries from OSM
BN = ox.geometries_from_bbox(40.550055, 40.436808, -88.917847, -89.032860,
tags={'building':True})

#The data cannot be in a geographic coordinate system for momepy to run correctly
BN_projected = ox.projection.project_gdf(BN)

#Explode muti-part geometries into multiple single geometries.
BN_exploded = BN_projected.explode()

#Strip out polygons from exploded gdf
BN_exploded_poly = BN_exploded.loc[BN_exploded.geometry.type=='Polygon',:]

#Check to make sure all non-polygon geometries have been removed
BN_exploded_poly.geometry

#Reset index - this is a necessary step due to a bug in geopandas
BN_exploded_poly = BN_exploded_poly.reset_index()

print(type(BN_exploded_poly))

#Run building data preprocessing
BN_buildings = momepy.preprocess(BN_exploded_poly, size=30, compactness=0.2, islands=True)

Versions of your packages

momepy='0.5.4'
geopandas='0.12.2'
osmnx='1.2.2'

Your operating system

Windows 10 Enterprise, 64-bit

Additional context

I am returning to this code. It worked seamlessly 14 months ago and I have been unable to riddle out the errors I now encounter. Likely this is something wrong on my end, but over the past few days I've done all I can to solve the problem before reaching out here.

@matthewhiett matthewhiett added the bug Something isn't working label Apr 18, 2023
@martinfleis
Copy link
Member

We should deprecate momepy.preprocess and extract its parts into individual functions...

The error comes from code that is sub-optimal and shall be refactored on our side.

Anyway, I am not able to reproduce it, so no idea what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants