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

polygon_query() support for images #358

Merged
merged 3 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/spatialdata/_core/query/spatial_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,15 @@ def polygon_query(
# TODO: the performance for this case can be greatly improved by using the geopandas queries only once, and not
# in a loop as done preliminarily here
if points or images or labels:
raise NotImplementedError(
"points=True, images=True and labels=True are not implemented when querying by multiple polygons. "
"If you encounter this error, please"
" open an issue on GitHub and we will prioritize the implementation."
logger.warning(
"Spatial querying of images, points and labels is not implemented when querying by multiple polygons "
'simultaneously. You can silence this warning by setting "points=False, images=False, labels=False". If '
"you need this implementation please open an issue on GitHub and we will prioritize the implementation."
LucaMarconato marked this conversation as resolved.
Show resolved Hide resolved
)
points = False
images = False
labels = False

sdatas = []
for polygon in tqdm(polygons):
try:
Expand Down
6 changes: 5 additions & 1 deletion tests/core/query/test_spatial_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ def test_polygon_query_shapes(sdata_query_aggregation):
circle_pol = circle.buffer(sdata["by_circles"].radius.iloc[0])

queried = polygon_query(
values_sdata, polygons=polygon, target_coordinate_system="global", shapes=True, points=False
values_sdata,
polygons=polygon,
target_coordinate_system="global",
shapes=True,
points=False,
)
assert len(queried["values_polygons"]) == 4
assert len(queried["values_circles"]) == 4
Expand Down
Loading