Skip to content

Implement a geodataframe class #116

@cojmeister

Description

@cojmeister

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 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions