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

Remove CONUS/AK Search Constraint (cryocloud dev) #10

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 2 additions & 12 deletions src/coincident/search/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

# Used to access formatters
from pystac_client.item_search import ItemSearch as _ItemSearch
from shapely.geometry import box

from coincident.datasets import _alias_to_Dataset
from coincident.datasets.general import Dataset
Expand Down Expand Up @@ -171,7 +170,7 @@ def _validate_spatial_bounds(
intersects: gpd.GeoSeries,
) -> None:
"""
Validate that the specified area of interest (AOI) within CONUS or Alaska.
Validate that the specified area of interest (AOI) is type GeoDataFrame or GeoSeries
Parameters
----------
dataset : _Dataset
Expand All @@ -181,20 +180,11 @@ def _validate_spatial_bounds(
Raises
------
ValueError
If the AOI is not within the bounds of the Continental U.S. or Alaska.
If the AOI is not type GeoDataFrame or GeoSeries
"""
if not isinstance(intersects, gpd.GeoDataFrame | gpd.GeoSeries):
message = f"intersects value must be a GeoDataFrame or GeoSeries, not {type(intersects)}"
raise ValueError(message)
if len(intersects) > 1:
message = "GeoDataFrame contains multiple geometries, search requires a single geometry"
raise ValueError(message)

# NOTE: use geopandas to first convert to projected CRS?
aoi = intersects.to_crs("EPSG:4326").geometry.iloc[0] # shapely geometry
CONUS = box(*(-124.84, 24.39, -66.88, 49.38))
AK = box(*(-179.99, 51.21, -129.63, 71.35))
if not aoi.within(CONUS) and not aoi.within(AK):
message = "Requested search polygon not within Continental U.S. or Alaska"
raise ValueError(message)
# warnings.warn(f'Requested search polygon not within Continental U.S. or Alaska')
19 changes: 0 additions & 19 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,6 @@ def test_polygon_invalid_type():
m.search.search(dataset="3dep", intersects="-120, 40, -121, 41")


# For now raise an error to not complicate things
def test_polygon_out_of_bounds():
feature_coll = {
"type": "FeatureCollection",
"features": [
{
"id": "0",
"properties": {"col1": "name1"},
"type": "Feature",
"geometry": {"type": "Point", "coordinates": (1.0, 2.0)},
}
],
}
aoi = gpd.GeoDataFrame.from_features(feature_coll, crs="EPSG:4326")
# with pytest.warns(UserWarning, match="Requested search polygon not within"):
with pytest.raises(ValueError, match="Requested search polygon not within"):
m.search.search(dataset="3dep", intersects=aoi)


# TODO: add more assertions / tests for this section
@network
@pytest.mark.filterwarnings("ignore:Server does not conform")
Expand Down
Loading