Check validity of shapely geometries in `ShapesModel.parse()`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 7
Description
In tests/conftest.py the second multipolygon of the multipoly object is invalid, i.e.
multipoly = GeoDataFrame(
{
"geometry": [
MultiPolygon(
[
Polygon(((0, 0), (0, 1), (1, 1), (1, 0))),
Polygon(((0, 0), (0, -1), (-1, -1), (-1, 0))),
]
),
MultiPolygon(
[
Polygon(((0, 0), (0, 1), (1, 10))),
Polygon(((0, 0), (0, 1), (1, 1))),
Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (1, 0))),
]
),
]
}
leads to multipoly.is_valid having False at the second entry.
This may cause subtle problems when operating on those objects; for instance this query fails:
indices = polygons.geometry.intersects(bounding_box_non_axes_aligned)
A solution is to prevent such geometries to pass the validation step when invoking parse() and validate() in ShapesModel.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ShapesModel.parse() and validate(), then inspect the invalid multipoly fixture in tests/conftest.py. Reproduce the failing geometry operation using polygons.geometry.intersects(bounding_box_non_axes_aligned). Done means invalid shapely geometries are rejected during ShapesModel parsing and validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100