diff --git a/src/spatialdata/_core/query/spatial_query.py b/src/spatialdata/_core/query/spatial_query.py index 04473bb9..b0386cd2 100644 --- a/src/spatialdata/_core/query/spatial_query.py +++ b/src/spatialdata/_core/query/spatial_query.py @@ -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." ) + points = False + images = False + labels = False + sdatas = [] for polygon in tqdm(polygons): try: diff --git a/tests/core/query/test_spatial_query.py b/tests/core/query/test_spatial_query.py index 29eeff5d..6db7e904 100644 --- a/tests/core/query/test_spatial_query.py +++ b/tests/core/query/test_spatial_query.py @@ -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