Skip to content

Graph.from_geodataframe(): attribute error for Polygon.id #423

@arulandu

Description

@arulandu

I'm working with some dummy county data using geopandas/shapely. Running the following line errors:
graph = Graph.from_geodataframe(guilford_county, adjacency='queen')

File ~/.../python3.12/site-packages/gerrychain/graph/adjacency.py:21, in str_tree(geometries)
     17 """Add ids to geometries and create a STR tree for spatial indexing.
     18 Use this for all spatial operations!
     19 """
     20 for i in geometries.index:
---> 21     geometries[i].id = i
     22 try:
     23     tree = STRtree(geometries)
     ```

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

It seems like the `id` property on Polygon doesn't exist, but a `uid` does. Is this library out of date?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions