Skip to content

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

@matthewhiett

Description

@matthewhiett

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions