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

Graph.from_geodataframe() fails without crs #417

Open
RKBuck1 opened this issue Jan 30, 2024 · 0 comments
Open

Graph.from_geodataframe() fails without crs #417

RKBuck1 opened this issue Jan 30, 2024 · 0 comments

Comments

@RKBuck1
Copy link
Member

RKBuck1 commented Jan 30, 2024

I'm working with some toy data that doesn't have a crs and getting the following error from Graph.geodataframe():

AttributeError                            Traceback (most recent call last)
[<ipython-input-12-0266b8024caa>](https://localhost:8080/#) in <cell line: 1>()
----> 1 graph = Graph.from_geodataframe(zones, reproject = False)

[/usr/local/lib/python3.10/dist-packages/gerrychain/graph/graph.py](https://localhost:8080/#) in from_geodataframe(cls, dataframe, adjacency, cols_to_add, reproject, ignore_errors)
    181 
    182         graph.add_data(df, columns=cols_to_add)
--> 183         graph.graph["crs"] = df.crs.to_json()
    184         return graph
    185 

AttributeError: 'NoneType' object has no attribute 'to_json' 

I can work around it by setting the crs to a pseudo Plate Carrée projection, but it seems like it might make more sense to issue a warning here instead if the GeoDataFrame doesn't already have a crs assigned

@RKBuck1 RKBuck1 changed the title Graph.from_geodatafram() fails without crs Graph.from_geodataframe() fails without crs Jan 30, 2024
peterrrock2 added a commit that referenced this issue Apr 28, 2024
@peterrrock2 peterrrock2 mentioned this issue Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant