scverse / scverse/spatialdata

Models: mixed types for the same shape column

Open
#214 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

element: shapes ▲ needs: triage priority: low
Dominant language
Python
Stars
394
Forks
95
Avg merge
4d 3h
Merged PRs (30d)
7

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the schema validation and utility code for GeoDataFrame geometry columns, then review the proposed get_geoseries_types function and the design documentation. Add validation for Point-only columns or columns containing Polygons and/or Multipolygons, and update the design doc with these assumptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, documentation
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.