spatialdata icon indicating copy to clipboard operation
spatialdata copied to clipboard

Models: mixed types for the same shape column

Open LucaMarconato opened this issue 2 years ago • 0 comments

Right now in the schema we don't check if a GeoDataFrame shapes object contains mixed types.

I would allow only the following two cases:

  • [ ] The geometry column is only made by Point, no other types allowed;
  • [ ] The geometry column is made by Polygons and/or Multipolygons.

A function to check this is the following, we could out it in the validation schema, or if is expensive, just put it somewhere in the utils:

from geopandas import GeoDataFrame
from typing import Any


def get_geoseries_types(gdf: GeoDataFrame) -> set[Any]:
    types = set()
    geom = gdf.geometry
    for i in range(len(geom)):
        x = geom.iloc[i]
        types.add(type(x))
    return types
  • [ ] Finally, we should update the design doc with the above assumptions.

LucaMarconato avatar Apr 05 '23 14:04 LucaMarconato