terrakio-core 0.2.7__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of terrakio-core might be problematic. Click here for more details.
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/PKG-INFO +2 -1
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/pyproject.toml +2 -1
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/__init__.py +1 -1
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/client.py +21 -6
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core.egg-info/PKG-INFO +2 -1
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core.egg-info/requires.txt +1 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/README.md +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/setup.cfg +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/auth.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/config.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/dataset_management.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/exceptions.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/group_access_management.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/mass_stats.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/space_management.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core/user_management.py +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core.egg-info/SOURCES.txt +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core.egg-info/dependency_links.txt +0 -0
- {terrakio_core-0.2.7 → terrakio_core-0.3.0}/terrakio_core.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: terrakio-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Core components for Terrakio API clients
|
|
5
5
|
Author-email: Yupeng Chao <yupeng@haizea.com.au>
|
|
6
6
|
Project-URL: Homepage, https://github.com/HaizeaAnalytics/terrakio-python-api
|
|
@@ -21,6 +21,7 @@ Requires-Dist: pyyaml>=5.1
|
|
|
21
21
|
Requires-Dist: xarray>=2023.1.0
|
|
22
22
|
Requires-Dist: shapely>=2.0.0
|
|
23
23
|
Requires-Dist: geopandas>=0.13.0
|
|
24
|
+
Requires-Dist: google-cloud-storage>=2.0.0
|
|
24
25
|
|
|
25
26
|
# Terrakio Core
|
|
26
27
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "terrakio-core"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
authors = [
|
|
9
9
|
{name = "Yupeng Chao", email = "yupeng@haizea.com.au"},
|
|
10
10
|
]
|
|
@@ -28,6 +28,7 @@ dependencies = [
|
|
|
28
28
|
"xarray>=2023.1.0",
|
|
29
29
|
"shapely>=2.0.0",
|
|
30
30
|
"geopandas>=0.13.0",
|
|
31
|
+
"google-cloud-storage>=2.0.0",
|
|
31
32
|
]
|
|
32
33
|
|
|
33
34
|
[project.urls]
|
|
@@ -91,7 +91,7 @@ class BaseClient:
|
|
|
91
91
|
|
|
92
92
|
async def wcs_async(self, expr: str, feature: Union[Dict[str, Any], ShapelyGeometry],
|
|
93
93
|
in_crs: str = "epsg:4326", out_crs: str = "epsg:4326",
|
|
94
|
-
output: str = "csv", resolution: int = -1, buffer: bool =
|
|
94
|
+
output: str = "csv", resolution: int = -1, buffer: bool = False,
|
|
95
95
|
retry: int = 3, **kwargs):
|
|
96
96
|
"""
|
|
97
97
|
Asynchronous version of the wcs() method using aiohttp.
|
|
@@ -129,16 +129,13 @@ class BaseClient:
|
|
|
129
129
|
"resolution": resolution,
|
|
130
130
|
**kwargs
|
|
131
131
|
}
|
|
132
|
-
|
|
133
132
|
request_url = f"{self.url}/geoquery"
|
|
134
|
-
|
|
135
133
|
for attempt in range(retry + 1):
|
|
136
134
|
try:
|
|
137
135
|
session = await self.aiohttp_session
|
|
138
136
|
async with session.post(request_url, json=payload, ssl=self.verify) as response:
|
|
139
137
|
if not response.ok:
|
|
140
138
|
should_retry = False
|
|
141
|
-
|
|
142
139
|
if response.status in [408, 502, 503, 504]:
|
|
143
140
|
should_retry = True
|
|
144
141
|
elif response.status == 500:
|
|
@@ -684,7 +681,7 @@ class BaseClient:
|
|
|
684
681
|
return self.mass_stats.random_sample(name, **kwargs)
|
|
685
682
|
|
|
686
683
|
async def zonal_stats_async(self, gdb, expr, conc=20, inplace=False, output="csv",
|
|
687
|
-
in_crs="epsg:4326", out_crs="epsg:4326", resolution
|
|
684
|
+
in_crs="epsg:4326", out_crs="epsg:4326", resolution=-1, buffer=False):
|
|
688
685
|
"""
|
|
689
686
|
Compute zonal statistics for all geometries in a GeoDataFrame using asyncio for concurrency.
|
|
690
687
|
|
|
@@ -709,6 +706,13 @@ class BaseClient:
|
|
|
709
706
|
all_results = []
|
|
710
707
|
row_indices = []
|
|
711
708
|
|
|
709
|
+
# Calculate total batches for progress reporting
|
|
710
|
+
total_geometries = len(gdb)
|
|
711
|
+
total_batches = (total_geometries + conc - 1) // conc # Ceiling division
|
|
712
|
+
completed_batches = 0
|
|
713
|
+
|
|
714
|
+
print(f"Processing {total_geometries} geometries with concurrency {conc}")
|
|
715
|
+
|
|
712
716
|
async def process_geometry(geom, index):
|
|
713
717
|
"""Process a single geometry"""
|
|
714
718
|
try:
|
|
@@ -760,11 +764,19 @@ class BaseClient:
|
|
|
760
764
|
batch_results = await process_batch(batch_indices)
|
|
761
765
|
all_results.extend(batch_results)
|
|
762
766
|
row_indices.extend(batch_indices)
|
|
767
|
+
|
|
768
|
+
# Update progress
|
|
769
|
+
completed_batches += 1
|
|
770
|
+
processed_geometries = min(i + conc, total_geometries)
|
|
771
|
+
print(f"Progress: {completed_batches}/{total_batches} completed ({processed_geometries}/{total_geometries} geometries processed)")
|
|
772
|
+
|
|
763
773
|
except Exception as e:
|
|
764
774
|
if hasattr(e, 'response'):
|
|
765
775
|
raise APIError(f"API request failed: {e.response.text}")
|
|
766
776
|
raise
|
|
767
777
|
|
|
778
|
+
print("All batches completed! Processing results...")
|
|
779
|
+
|
|
768
780
|
if not all_results:
|
|
769
781
|
raise ValueError("No valid results were returned for any geometry")
|
|
770
782
|
|
|
@@ -857,7 +869,7 @@ class BaseClient:
|
|
|
857
869
|
return result_gdf
|
|
858
870
|
|
|
859
871
|
def zonal_stats(self, gdb, expr, conc=20, inplace=False, output="csv",
|
|
860
|
-
in_crs="epsg:4326", out_crs="epsg:4326", resolution
|
|
872
|
+
in_crs="epsg:4326", out_crs="epsg:4326", resolution=-1, buffer=False):
|
|
861
873
|
"""
|
|
862
874
|
Compute zonal statistics for all geometries in a GeoDataFrame.
|
|
863
875
|
|
|
@@ -879,6 +891,8 @@ class BaseClient:
|
|
|
879
891
|
raise ValueError("Concurrency (conc) is too high. Please set conc to 100 or less.")
|
|
880
892
|
import asyncio
|
|
881
893
|
|
|
894
|
+
print(f"Starting zonal statistics computation for expression: {expr}")
|
|
895
|
+
|
|
882
896
|
# Check if we're in a Jupyter environment or already have an event loop
|
|
883
897
|
try:
|
|
884
898
|
loop = asyncio.get_running_loop()
|
|
@@ -912,6 +926,7 @@ class BaseClient:
|
|
|
912
926
|
# Event loop may already be closed, ignore
|
|
913
927
|
pass
|
|
914
928
|
|
|
929
|
+
print("Zonal statistics computation completed!")
|
|
915
930
|
return result
|
|
916
931
|
|
|
917
932
|
# Group access management protected methods
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: terrakio-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Core components for Terrakio API clients
|
|
5
5
|
Author-email: Yupeng Chao <yupeng@haizea.com.au>
|
|
6
6
|
Project-URL: Homepage, https://github.com/HaizeaAnalytics/terrakio-python-api
|
|
@@ -21,6 +21,7 @@ Requires-Dist: pyyaml>=5.1
|
|
|
21
21
|
Requires-Dist: xarray>=2023.1.0
|
|
22
22
|
Requires-Dist: shapely>=2.0.0
|
|
23
23
|
Requires-Dist: geopandas>=0.13.0
|
|
24
|
+
Requires-Dist: google-cloud-storage>=2.0.0
|
|
24
25
|
|
|
25
26
|
# Terrakio Core
|
|
26
27
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|