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

geopandas integration, support arbitrary geometry column name #31

Open
rejexx opened this issue Feb 9, 2024 · 0 comments
Open

geopandas integration, support arbitrary geometry column name #31

rejexx opened this issue Feb 9, 2024 · 0 comments

Comments

@rejexx
Copy link

rejexx commented Feb 9, 2024

Awesome project, makes life much easier.

It seems like this could use a tighter geopandas integration.
I noticed that this assumes the geometry column is named "geometry" which is not always the case.

You can get the active geometry column name with gdf.geometry.name where gdf.geometry attribute is always the active geometry. This works in geopandas 0.14.2.

I peaked at the source code, it seems like sometimes the gdf.geometry attribute is used in the source, but maybe it just looks for a column named "geometry" because it assumes it's a pandas dataframe. I'm not sure

Reproduction steps

I noticed this when running code something like this:

gdf = gdf.set_geometry("points_geometry")  # The only geometry column, contains several points
h3.geo_to_h3_aggregate(7, return_geometry=True)

I got this error:

TypeError: 'GeometryArray' with dtype geometry does not support reduction 'sum'

The above exception was the direct cause of the following exception:

TypeError: agg function failed [how->sum,dtype->geometry]

If I rename and drop the original geometry, it works

gdf["geometry"] = gdf.points_geometry
gdf = gdf.set_geometry("geometry").drop(columns="points_geometry")
   
h3agg = gdf.h3.geo_to_h3_aggregate(7, return_geometry=True)
@rejexx rejexx changed the title geopandas integration, add arbitrary geometry column name geopandas integration, support arbitrary geometry column name Feb 9, 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