geoai-py 0.8.3__py2.py3-none-any.whl → 0.9.1__py2.py3-none-any.whl
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.
- geoai/__init__.py +1 -1
- geoai/change_detection.py +1568 -0
- geoai/classify.py +58 -57
- geoai/detectron2.py +466 -0
- geoai/download.py +74 -68
- geoai/extract.py +186 -141
- geoai/geoai.py +13 -11
- geoai/hf.py +14 -12
- geoai/segment.py +44 -39
- geoai/segmentation.py +10 -9
- geoai/train.py +372 -241
- geoai/utils.py +198 -123
- {geoai_py-0.8.3.dist-info → geoai_py-0.9.1.dist-info}/METADATA +5 -1
- geoai_py-0.9.1.dist-info/RECORD +19 -0
- geoai_py-0.8.3.dist-info/RECORD +0 -17
- {geoai_py-0.8.3.dist-info → geoai_py-0.9.1.dist-info}/WHEEL +0 -0
- {geoai_py-0.8.3.dist-info → geoai_py-0.9.1.dist-info}/entry_points.txt +0 -0
- {geoai_py-0.8.3.dist-info → geoai_py-0.9.1.dist-info}/licenses/LICENSE +0 -0
- {geoai_py-0.8.3.dist-info → geoai_py-0.9.1.dist-info}/top_level.txt +0 -0
geoai/download.py
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
import logging
|
4
4
|
import os
|
5
5
|
import subprocess
|
6
|
-
from typing import Any, Dict, List, Optional, Tuple
|
6
|
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
7
7
|
|
8
8
|
import geopandas as gpd
|
9
9
|
import matplotlib.pyplot as plt
|
@@ -252,7 +252,7 @@ def get_overture_latest_release(patch=True) -> str:
|
|
252
252
|
raise
|
253
253
|
|
254
254
|
|
255
|
-
def get_all_overture_types():
|
255
|
+
def get_all_overture_types() -> List[str]:
|
256
256
|
"""Get a list of all available Overture Maps data types.
|
257
257
|
|
258
258
|
Returns:
|
@@ -437,15 +437,15 @@ def extract_building_stats(data: str) -> Dict[str, Any]:
|
|
437
437
|
|
438
438
|
|
439
439
|
def download_pc_stac_item(
|
440
|
-
item_url,
|
441
|
-
bands=None,
|
442
|
-
output_dir=None,
|
443
|
-
show_progress=True,
|
444
|
-
merge_bands=False,
|
445
|
-
merged_filename=None,
|
446
|
-
overwrite=False,
|
447
|
-
cell_size=None,
|
448
|
-
):
|
440
|
+
item_url: str,
|
441
|
+
bands: Optional[List[str]] = None,
|
442
|
+
output_dir: Optional[str] = None,
|
443
|
+
show_progress: bool = True,
|
444
|
+
merge_bands: bool = False,
|
445
|
+
merged_filename: Optional[str] = None,
|
446
|
+
overwrite: bool = False,
|
447
|
+
cell_size: Optional[float] = None,
|
448
|
+
) -> Dict[str, Any]:
|
449
449
|
"""
|
450
450
|
Downloads a STAC item from Microsoft Planetary Computer with specified bands.
|
451
451
|
|
@@ -686,11 +686,11 @@ def download_pc_stac_item(
|
|
686
686
|
|
687
687
|
|
688
688
|
def pc_collection_list(
|
689
|
-
endpoint="https://planetarycomputer.microsoft.com/api/stac/v1",
|
690
|
-
detailed=False,
|
691
|
-
filter_by=None,
|
692
|
-
sort_by="id",
|
693
|
-
):
|
689
|
+
endpoint: str = "https://planetarycomputer.microsoft.com/api/stac/v1",
|
690
|
+
detailed: bool = False,
|
691
|
+
filter_by: Optional[str] = None,
|
692
|
+
sort_by: str = "id",
|
693
|
+
) -> List[Dict[str, Any]]:
|
694
694
|
"""
|
695
695
|
Retrieves and displays the list of available collections from Planetary Computer.
|
696
696
|
|
@@ -813,14 +813,14 @@ def pc_collection_list(
|
|
813
813
|
|
814
814
|
|
815
815
|
def pc_stac_search(
|
816
|
-
collection,
|
817
|
-
bbox=None,
|
818
|
-
time_range=None,
|
819
|
-
query=None,
|
820
|
-
limit=10,
|
821
|
-
max_items=None,
|
822
|
-
endpoint="https://planetarycomputer.microsoft.com/api/stac/v1",
|
823
|
-
):
|
816
|
+
collection: str,
|
817
|
+
bbox: Optional[List[float]] = None,
|
818
|
+
time_range: Optional[str] = None,
|
819
|
+
query: Optional[Dict[str, Any]] = None,
|
820
|
+
limit: int = 10,
|
821
|
+
max_items: Optional[int] = None,
|
822
|
+
endpoint: str = "https://planetarycomputer.microsoft.com/api/stac/v1",
|
823
|
+
) -> List["pystac.Item"]:
|
824
824
|
"""
|
825
825
|
Search for STAC items in the Planetary Computer catalog.
|
826
826
|
|
@@ -902,12 +902,12 @@ def pc_stac_search(
|
|
902
902
|
|
903
903
|
|
904
904
|
def pc_stac_download(
|
905
|
-
items,
|
906
|
-
output_dir=".",
|
907
|
-
assets=None,
|
908
|
-
max_workers=1,
|
909
|
-
skip_existing=True,
|
910
|
-
):
|
905
|
+
items: Union["pystac.Item", List["pystac.Item"]],
|
906
|
+
output_dir: str = ".",
|
907
|
+
assets: Optional[List[str]] = None,
|
908
|
+
max_workers: int = 1,
|
909
|
+
skip_existing: bool = True,
|
910
|
+
) -> Dict[str, Dict[str, str]]:
|
911
911
|
"""
|
912
912
|
Download assets from STAC items retrieved from the Planetary Computer.
|
913
913
|
|
@@ -925,8 +925,6 @@ def pc_stac_download(
|
|
925
925
|
Defaults to 1.
|
926
926
|
skip_existing (bool, optional): Skip download if the file already exists.
|
927
927
|
Defaults to True.
|
928
|
-
sign_urls (bool, optional): Whether to sign URLs for authenticated access.
|
929
|
-
Defaults to True.
|
930
928
|
|
931
929
|
Returns:
|
932
930
|
dict: Dictionary mapping STAC item IDs to dictionaries of their downloaded
|
@@ -949,7 +947,9 @@ def pc_stac_download(
|
|
949
947
|
os.makedirs(output_dir, exist_ok=True)
|
950
948
|
|
951
949
|
# Function to download a single asset
|
952
|
-
def download_asset(
|
950
|
+
def download_asset(
|
951
|
+
item: "pystac.Item", asset_key: str, asset: "pystac.Asset"
|
952
|
+
) -> str:
|
953
953
|
item = pc.sign(item)
|
954
954
|
item_id = item.id
|
955
955
|
|
@@ -1059,7 +1059,7 @@ def pc_stac_download(
|
|
1059
1059
|
return results
|
1060
1060
|
|
1061
1061
|
|
1062
|
-
def pc_item_asset_list(item):
|
1062
|
+
def pc_item_asset_list(item: Union[str, "pystac.Item"]) -> List[str]:
|
1063
1063
|
"""
|
1064
1064
|
Retrieve the list of asset keys from a STAC item in the Planetary Computer catalog.
|
1065
1065
|
|
@@ -1078,7 +1078,13 @@ def pc_item_asset_list(item):
|
|
1078
1078
|
return list(item.assets.keys())
|
1079
1079
|
|
1080
1080
|
|
1081
|
-
def read_pc_item_asset(
|
1081
|
+
def read_pc_item_asset(
|
1082
|
+
item: Union[str, "pystac.Item"],
|
1083
|
+
asset: str,
|
1084
|
+
output: Optional[str] = None,
|
1085
|
+
as_cog: bool = True,
|
1086
|
+
**kwargs: Any,
|
1087
|
+
) -> "xr.Dataset":
|
1082
1088
|
"""
|
1083
1089
|
Read a specific asset from a STAC item in the Planetary Computer catalog.
|
1084
1090
|
|
@@ -1118,23 +1124,23 @@ def read_pc_item_asset(item, asset, output=None, as_cog=True, **kwargs):
|
|
1118
1124
|
|
1119
1125
|
|
1120
1126
|
def view_pc_item(
|
1121
|
-
url=None,
|
1122
|
-
collection=None,
|
1123
|
-
item=None,
|
1124
|
-
assets=None,
|
1125
|
-
bands=None,
|
1126
|
-
titiler_endpoint=None,
|
1127
|
-
name="STAC Item",
|
1128
|
-
attribution="Planetary Computer",
|
1129
|
-
opacity=1.0,
|
1130
|
-
shown=True,
|
1131
|
-
fit_bounds=True,
|
1132
|
-
layer_index=None,
|
1133
|
-
backend="folium",
|
1134
|
-
basemap=None,
|
1135
|
-
map_args=None,
|
1136
|
-
**kwargs,
|
1137
|
-
):
|
1127
|
+
url: Optional[str] = None,
|
1128
|
+
collection: Optional[str] = None,
|
1129
|
+
item: Optional[str] = None,
|
1130
|
+
assets: Optional[Union[str, List[str]]] = None,
|
1131
|
+
bands: Optional[List[str]] = None,
|
1132
|
+
titiler_endpoint: Optional[str] = None,
|
1133
|
+
name: str = "STAC Item",
|
1134
|
+
attribution: str = "Planetary Computer",
|
1135
|
+
opacity: float = 1.0,
|
1136
|
+
shown: bool = True,
|
1137
|
+
fit_bounds: bool = True,
|
1138
|
+
layer_index: Optional[int] = None,
|
1139
|
+
backend: str = "folium",
|
1140
|
+
basemap: Optional[str] = None,
|
1141
|
+
map_args: Optional[Dict[str, Any]] = None,
|
1142
|
+
**kwargs: Any,
|
1143
|
+
) -> Any:
|
1138
1144
|
"""
|
1139
1145
|
Visualize a STAC item from the Planetary Computer on an interactive map.
|
1140
1146
|
|
@@ -1214,22 +1220,22 @@ def view_pc_item(
|
|
1214
1220
|
|
1215
1221
|
|
1216
1222
|
def view_pc_items(
|
1217
|
-
urls=None,
|
1218
|
-
collection=None,
|
1219
|
-
items=None,
|
1220
|
-
assets=None,
|
1221
|
-
bands=None,
|
1222
|
-
titiler_endpoint=None,
|
1223
|
-
attribution="Planetary Computer",
|
1224
|
-
opacity=1.0,
|
1225
|
-
shown=True,
|
1226
|
-
fit_bounds=True,
|
1227
|
-
layer_index=None,
|
1228
|
-
backend="folium",
|
1229
|
-
basemap=None,
|
1230
|
-
map_args=None,
|
1231
|
-
**kwargs,
|
1232
|
-
):
|
1223
|
+
urls: Optional[List[str]] = None,
|
1224
|
+
collection: Optional[str] = None,
|
1225
|
+
items: Optional[List[str]] = None,
|
1226
|
+
assets: Optional[Union[str, List[str]]] = None,
|
1227
|
+
bands: Optional[List[str]] = None,
|
1228
|
+
titiler_endpoint: Optional[str] = None,
|
1229
|
+
attribution: str = "Planetary Computer",
|
1230
|
+
opacity: float = 1.0,
|
1231
|
+
shown: bool = True,
|
1232
|
+
fit_bounds: bool = True,
|
1233
|
+
layer_index: Optional[int] = None,
|
1234
|
+
backend: str = "folium",
|
1235
|
+
basemap: Optional[str] = None,
|
1236
|
+
map_args: Optional[Dict[str, Any]] = None,
|
1237
|
+
**kwargs: Any,
|
1238
|
+
) -> Any:
|
1233
1239
|
"""
|
1234
1240
|
Visualize multiple STAC items from the Planetary Computer on an interactive map.
|
1235
1241
|
|