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

Implement a geodataframe class #116

Open
cojmeister opened this issue Mar 11, 2024 · 0 comments
Open

Implement a geodataframe class #116

cojmeister opened this issue Mar 11, 2024 · 0 comments

Comments

@cojmeister
Copy link

Implement a geodataframe typing that can be use to check geodataframes - as of now my static tests with beartype fail when using this. Beartype is right to fail this.

Example of failing code.

import geopandas as gpd
import shapely
from nptyping import DataFrame, Structure as S
from beartype import beartype

gdf = gpd.GeoDataFrame(
    {"center_x": [0, 1], "center_y": [0, 1]}
)
gdf['geometry'] = gdf.apply(lambda row: shapely.Point(row["center_x"], row["center_y"]).buffer(10), axis=1)

gdf.set_geometry("geometry", inplace=True)


@beartype
def some_function(some_geodataframe: DataFrame[S["center_x: Float, center_y: Float, geometry: Polygon"]]) -> None:
    print(some_geodataframe)


some_function(gdf)

Proposed solution:

Create a geodataframe class that just inherits from dataframe and has a geometry column that will be a shapely geometry (a bit to general). Another option is to allow for classes that inherit from dataframe.

I am willing to write the code and do the changes 😊

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