Skip to content

Commit b28454c

Browse files
committed
feat: required region arg to init stac client
1 parent 52433cc commit b28454c

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

swisstopopy/buildings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def get_bldg_gdf(
117117
)
118118

119119
# use the STAC API to get building heights from swissSURFACE3D and swissALTI3D
120-
client = stac.SwissTopoClient(region=region_gser)
120+
client = stac.SwissTopoClient(region_gser)
121121

122122
# surface3d-raster (raster dsm)
123123
surface3d_gdf = client.gdf_from_collection(

swisstopopy/dem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_dem_raster(
4747
`settings.RIO_MERGE_DST_KWARGS` are used.
4848
"""
4949
# use the STAC API to get the DEM from swissALTI3D
50-
client = stac.SwissTopoClient(region=region, region_crs=region_crs)
50+
client = stac.SwissTopoClient(region, region_crs=region_crs)
5151
alti3d_gdf = client.gdf_from_collection(
5252
stac.SWISSALTI3D_COLLECTION_ID,
5353
datetime=alti3d_datetime,

swisstopopy/stac.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,8 @@ class SwissTopoClient:
126126
127127
Parameters
128128
----------
129-
region : region-like, optional
129+
region : region-like
130130
Region to get the data for. Can any argument accepted by the pyregeon library.
131-
If None, all the collection data will be returned.
132131
region_crs : crs-like, optional
133132
Coordinate reference system (CRS) of the region. Required if `region` is a naive
134133
geometry or a list of bounding box coordinates. Ignored if `region` already has
@@ -138,8 +137,8 @@ class SwissTopoClient:
138137

139138
def __init__(
140139
self,
140+
region: RegionType,
141141
*,
142-
region: RegionType | None = None,
143142
region_crs: CRSType = None,
144143
):
145144
"""Initialize a swisstopo client."""

swisstopopy/tree_canopy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_tree_canopy_raster(
105105
# note that we need to pass the STAC client's CRS to both `_process_region_arg` and
106106
# `to_crs`, because `region` may have another CRS and we need the extend in the
107107
# client's CRS
108-
client = stac.SwissTopoClient(region=region, region_crs=region_crs)
108+
client = stac.SwissTopoClient(region, region_crs=region_crs)
109109
surface3d_gdf = client.gdf_from_collection(
110110
stac.SWISSSURFACE3D_COLLECTION_ID,
111111
datetime=surface3d_datetime,

tests/test_swisstopopy.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@ def setUp(self):
1818
]
1919

2020
def test_region(self):
21-
# test without region (all collection items)
22-
client = swisstopopy.SwissTopoClient()
21+
# # test without region (all collection items)
22+
# client = swisstopopy.SwissTopoClient()
2323

24-
# since this is slow, test init one collection only
25-
collection_id = self.collection_ids[0]
26-
gdf = client.gdf_from_collection(collection_id)
24+
# # since this is slow, test init one collection only
25+
# collection_id = self.collection_ids[0]
26+
# gdf = client.gdf_from_collection(collection_id)
2727

2828
# test with region
2929
region_client = swisstopopy.SwissTopoClient(region=self.nominatim_query)
30-
# test that there are at most as many items as when not filtering spatially
31-
self.assertLessEqual(
32-
len(region_client.gdf_from_collection(collection_id).index), len(gdf.index)
33-
)
30+
# # test that there are at most as many items as when not filtering spatially
31+
# self.assertLessEqual(
32+
# len(region_client.gdf_from_collection(collection_id).index),
33+
# len(gdf.index)
34+
# )
3435
# test init all collections
3536
for collection_id in self.collection_ids:
3637
gdf = region_client.gdf_from_collection(collection_id)

0 commit comments

Comments
 (0)