geoai-py 0.4.1__tar.gz → 0.4.2__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.
- {geoai_py-0.4.1 → geoai_py-0.4.2}/PKG-INFO +6 -6
- {geoai_py-0.4.1 → geoai_py-0.4.2}/README.md +2 -4
- geoai_py-0.4.2/docs/assets/logo.ico +0 -0
- geoai_py-0.4.2/docs/assets/logo.png +0 -0
- geoai_py-0.4.2/docs/assets/logo_rect.png +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/building_footprints_usa.ipynb +1 -3
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/dataviz/lidar_viz.ipynb +1 -1
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/dataviz/raster_viz.ipynb +2 -2
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/dataviz/vector_viz.ipynb +3 -3
- geoai_py-0.4.2/docs/examples/download_sentinel2.ipynb +182 -0
- geoai_py-0.4.2/docs/examples/planetary_computer.ipynb +120 -0
- geoai_py-0.4.2/docs/examples/train_building_footprints_usa.ipynb +259 -0
- geoai_py-0.4.2/docs/examples/train_car_detection.ipynb +259 -0
- geoai_py-0.4.2/docs/examples/train_ship_detection.ipynb +257 -0
- geoai_py-0.4.2/docs/examples/train_solar_panel_detection.ipynb +255 -0
- geoai_py-0.4.2/docs/examples/wetland_mapping.ipynb +329 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/index.md +2 -4
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai/__init__.py +1 -1
- geoai_py-0.4.2/geoai/download.py +1040 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai/extract.py +518 -0
- geoai_py-0.4.2/geoai/geoai.py +15 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai/train.py +98 -12
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai/utils.py +240 -8
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai_py.egg-info/PKG-INFO +6 -6
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai_py.egg-info/SOURCES.txt +10 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai_py.egg-info/requires.txt +1 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/mkdocs.yml +9 -2
- {geoai_py-0.4.1 → geoai_py-0.4.2}/pyproject.toml +2 -2
- {geoai_py-0.4.1 → geoai_py-0.4.2}/requirements.txt +1 -0
- geoai_py-0.4.1/geoai/download.py +0 -396
- geoai_py-0.4.1/geoai/geoai.py +0 -7
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.editorconfig +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/FUNDING.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/dependabot.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/workflows/docs-build.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/workflows/docs.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/workflows/macos.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/workflows/pypi.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/workflows/ubuntu.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.github/workflows/windows.yml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.gitignore +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/.pre-commit-config.yaml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/LICENSE +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/MANIFEST.in +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/CNAME +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/changelog.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/contributing.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/download.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/_template.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/building_footprints_africa.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/building_footprints_china.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/building_regularization.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/car_detection.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/data_visualization.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/download_data.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/geometric_properties.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/image_chips.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/jupytext.toml +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/parking_spot_detection.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/arcgis.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/box_prompts.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/fast_sam.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/input_prompts.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/satellite.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/text_prompts.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/ship_detection.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/solar_panel_detection.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/text_prompt_segmentation.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/train_object_detection_model.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/examples/view_metadata.ipynb +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/extract.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/faq.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/geoai.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/hf.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/installation.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/overrides/main.html +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/segment.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/segmentation.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/train.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/usage.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/docs/utils.md +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai/hf.py +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai/segment.py +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai/segmentation.py +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai_py.egg-info/dependency_links.txt +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai_py.egg-info/entry_points.txt +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/geoai_py.egg-info/top_level.txt +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/requirements_docs.txt +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/setup.cfg +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/tests/__init__.py +0 -0
- {geoai_py-0.4.1 → geoai_py-0.4.2}/tests/test_geoai.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: geoai-py
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A Python package for using Artificial Intelligence (AI) with geospatial data
|
|
5
5
|
Author-email: Qiusheng Wu <giswqs@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -34,10 +34,12 @@ Requires-Dist: scikit-image
|
|
|
34
34
|
Requires-Dist: scikit-learn
|
|
35
35
|
Requires-Dist: torch
|
|
36
36
|
Requires-Dist: torchgeo
|
|
37
|
+
Requires-Dist: torchinfo
|
|
37
38
|
Requires-Dist: tqdm
|
|
38
39
|
Requires-Dist: transformers
|
|
39
40
|
Provides-Extra: extra
|
|
40
41
|
Requires-Dist: overturemaps; extra == "extra"
|
|
42
|
+
Dynamic: license-file
|
|
41
43
|
|
|
42
44
|
# GeoAI: Artificial Intelligence for Geospatial Data
|
|
43
45
|
|
|
@@ -49,6 +51,8 @@ Requires-Dist: overturemaps; extra == "extra"
|
|
|
49
51
|
[](https://opensource.org/licenses/MIT)
|
|
50
52
|
[](https://bit.ly/GeoAI-Tutorials)
|
|
51
53
|
|
|
54
|
+
[](https://github.com/opengeos/geoai/blob/master/docs/assets/logo.png)
|
|
55
|
+
|
|
52
56
|
**A powerful Python package for integrating Artificial Intelligence with geospatial data analysis and visualization**
|
|
53
57
|
|
|
54
58
|
GeoAI bridges the gap between AI and geospatial analysis, providing tools for processing, analyzing, and visualizing geospatial data using advanced machine learning techniques. Whether you're working with satellite imagery, LiDAR point clouds, or vector data, GeoAI offers intuitive interfaces to apply cutting-edge AI models.
|
|
@@ -139,7 +143,3 @@ We welcome contributions of all kinds! See our [contributing guide](https://geoa
|
|
|
139
143
|
## 📄 License
|
|
140
144
|
|
|
141
145
|
GeoAI is free and open source software, licensed under the MIT License.
|
|
142
|
-
|
|
143
|
-
## 💖 Acknowledgment
|
|
144
|
-
|
|
145
|
-
Some of the pre-trained models used in the geoai package are adapted from the [ArcGIS Living Atlas](https://livingatlas.arcgis.com/en/browse/?q=dlpk#d=2&q=dlpk). Credits to Esri for making these models available.
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://bit.ly/GeoAI-Tutorials)
|
|
10
10
|
|
|
11
|
+
[](https://github.com/opengeos/geoai/blob/master/docs/assets/logo.png)
|
|
12
|
+
|
|
11
13
|
**A powerful Python package for integrating Artificial Intelligence with geospatial data analysis and visualization**
|
|
12
14
|
|
|
13
15
|
GeoAI bridges the gap between AI and geospatial analysis, providing tools for processing, analyzing, and visualizing geospatial data using advanced machine learning techniques. Whether you're working with satellite imagery, LiDAR point clouds, or vector data, GeoAI offers intuitive interfaces to apply cutting-edge AI models.
|
|
@@ -98,7 +100,3 @@ We welcome contributions of all kinds! See our [contributing guide](https://geoa
|
|
|
98
100
|
## 📄 License
|
|
99
101
|
|
|
100
102
|
GeoAI is free and open source software, licensed under the MIT License.
|
|
101
|
-
|
|
102
|
-
## 💖 Acknowledgment
|
|
103
|
-
|
|
104
|
-
Some of the pre-trained models used in the geoai package are adapted from the [ArcGIS Living Atlas](https://livingatlas.arcgis.com/en/browse/?q=dlpk#d=2&q=dlpk). Credits to Esri for making these models available.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -78,9 +78,7 @@
|
|
|
78
78
|
"cell_type": "markdown",
|
|
79
79
|
"metadata": {},
|
|
80
80
|
"source": [
|
|
81
|
-
"## Initialize building footprint extraction pretrained model
|
|
82
|
-
"\n",
|
|
83
|
-
"The pretained model is adapted from the Esri [building footprint extraction](https://www.arcgis.com/home/item.html?id=a6857359a1cd44839781a4f113cd5934) model for the USA. Credits to Esri for the model."
|
|
81
|
+
"## Initialize building footprint extraction pretrained model"
|
|
84
82
|
]
|
|
85
83
|
},
|
|
86
84
|
{
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"metadata": {},
|
|
145
145
|
"outputs": [],
|
|
146
146
|
"source": [
|
|
147
|
-
"dem_url = \"https://
|
|
147
|
+
"dem_url = \"https://opengeos.org/data/raster/srtm90.tif\"\n",
|
|
148
148
|
"leafmap.download_file(dem_url, unzip=False)"
|
|
149
149
|
]
|
|
150
150
|
},
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
"metadata": {},
|
|
184
184
|
"outputs": [],
|
|
185
185
|
"source": [
|
|
186
|
-
"landsat_url = \"https://
|
|
186
|
+
"landsat_url = \"https://opengeos.org/data/raster/cog.tif\"\n",
|
|
187
187
|
"leafmap.download_file(landsat_url)"
|
|
188
188
|
]
|
|
189
189
|
},
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"outputs": [],
|
|
63
63
|
"source": [
|
|
64
64
|
"m = leafmap.Map(center=[0, 0], zoom=2)\n",
|
|
65
|
-
"data = \"https://
|
|
65
|
+
"data = \"https://opengeos.org/data/vector/cables.geojson\"\n",
|
|
66
66
|
"m.add_vector(data, layer_name=\"Cable lines\", info_mode=\"on_hover\")\n",
|
|
67
67
|
"m"
|
|
68
68
|
]
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"source": [
|
|
93
93
|
"m = leafmap.Map(center=[20, 0], zoom=2)\n",
|
|
94
94
|
"m.add_basemap(\"CartoDB.DarkMatter\")\n",
|
|
95
|
-
"data = \"https://
|
|
95
|
+
"data = \"https://opengeos.org/data/vector/cables.geojson\"\n",
|
|
96
96
|
"callback = lambda feat: {\"color\": feat[\"properties\"][\"color\"], \"weight\": 1}\n",
|
|
97
97
|
"m.add_vector(data, layer_name=\"Cable lines\", style_callback=callback)\n",
|
|
98
98
|
"m"
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"metadata": {},
|
|
183
183
|
"outputs": [],
|
|
184
184
|
"source": [
|
|
185
|
-
"url = \"https://
|
|
185
|
+
"url = \"https://opengeos.org/data/duckdb/cities.parquet\"\n",
|
|
186
186
|
"gdf = leafmap.read_parquet(url, return_type=\"gdf\", src_crs=\"EPSG:4326\")\n",
|
|
187
187
|
"gdf.head()"
|
|
188
188
|
]
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Download Sentinel-2 Data from Planetary Computer\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/download_sentinel2.ipynb)\n",
|
|
10
|
+
"\n",
|
|
11
|
+
"The notebook demonstrates how to download Sentinel-2 data from the [Planetary Computer](https://planetarycomputer.microsoft.com/explore) using the `geoai` package.\n",
|
|
12
|
+
"\n",
|
|
13
|
+
"## Install package\n",
|
|
14
|
+
"To use the `geoai-py` package, ensure it is installed in your environment. Uncomment the command below if needed."
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"cell_type": "code",
|
|
19
|
+
"execution_count": null,
|
|
20
|
+
"metadata": {},
|
|
21
|
+
"outputs": [],
|
|
22
|
+
"source": [
|
|
23
|
+
"# %pip install geoai-py"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"cell_type": "markdown",
|
|
28
|
+
"metadata": {},
|
|
29
|
+
"source": [
|
|
30
|
+
"## Import libraries"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"cell_type": "code",
|
|
35
|
+
"execution_count": null,
|
|
36
|
+
"metadata": {},
|
|
37
|
+
"outputs": [],
|
|
38
|
+
"source": [
|
|
39
|
+
"import geoai"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"cell_type": "markdown",
|
|
44
|
+
"metadata": {},
|
|
45
|
+
"source": [
|
|
46
|
+
"## Search data\n",
|
|
47
|
+
"\n",
|
|
48
|
+
"Go to the [Planetary Computer](https://planetarycomputer.microsoft.com/explore) and search for the data you are interested in. Copy the STAC item link and paste it to the code below."
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"cell_type": "code",
|
|
53
|
+
"execution_count": null,
|
|
54
|
+
"metadata": {},
|
|
55
|
+
"outputs": [],
|
|
56
|
+
"source": [
|
|
57
|
+
"# Example for Sentinel-2 item\n",
|
|
58
|
+
"item_url = \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-2-l2a/items/S2B_MSIL2A_20250228T173149_R055_T14SLH_20250228T212633\""
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"cell_type": "markdown",
|
|
63
|
+
"metadata": {},
|
|
64
|
+
"source": [
|
|
65
|
+
"## Download sample data"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"cell_type": "code",
|
|
70
|
+
"execution_count": null,
|
|
71
|
+
"metadata": {},
|
|
72
|
+
"outputs": [],
|
|
73
|
+
"source": [
|
|
74
|
+
"# Specify which bands to download (Sentinel-2 bands)\n",
|
|
75
|
+
"bands_to_download = [\n",
|
|
76
|
+
" \"B01\",\n",
|
|
77
|
+
" \"B02\",\n",
|
|
78
|
+
" \"B03\",\n",
|
|
79
|
+
" \"B04\",\n",
|
|
80
|
+
" \"B05\",\n",
|
|
81
|
+
" \"B06\",\n",
|
|
82
|
+
" \"B07\",\n",
|
|
83
|
+
" \"B08\",\n",
|
|
84
|
+
" \"B8A\",\n",
|
|
85
|
+
" \"B09\",\n",
|
|
86
|
+
" \"B11\",\n",
|
|
87
|
+
" \"B12\",\n",
|
|
88
|
+
" \"AOT\",\n",
|
|
89
|
+
" \"WVP\",\n",
|
|
90
|
+
" \"SCL\",\n",
|
|
91
|
+
"]"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"cell_type": "code",
|
|
96
|
+
"execution_count": null,
|
|
97
|
+
"metadata": {},
|
|
98
|
+
"outputs": [],
|
|
99
|
+
"source": [
|
|
100
|
+
"# Create a directory for the downloaded bands\n",
|
|
101
|
+
"output_directory = \"sentinel2_bands\""
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"cell_type": "code",
|
|
106
|
+
"execution_count": null,
|
|
107
|
+
"metadata": {},
|
|
108
|
+
"outputs": [],
|
|
109
|
+
"source": [
|
|
110
|
+
"# Download the bands, save them to the output directory, and create a merged GeoTIFF.\n",
|
|
111
|
+
"# The download process may take a while. Please be patient.\n",
|
|
112
|
+
"downloaded_bands = geoai.download_pc_stac_item(\n",
|
|
113
|
+
" item_url=item_url,\n",
|
|
114
|
+
" bands=bands_to_download,\n",
|
|
115
|
+
" output_dir=output_directory,\n",
|
|
116
|
+
" show_progress=True,\n",
|
|
117
|
+
" merge_bands=True,\n",
|
|
118
|
+
" merged_filename=\"sentinel2_all_bands.tif\",\n",
|
|
119
|
+
" overwrite=False, # Skip files that already exist\n",
|
|
120
|
+
" cell_size=10, # Resample all bands to 10m resolution\n",
|
|
121
|
+
")"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"cell_type": "code",
|
|
126
|
+
"execution_count": null,
|
|
127
|
+
"metadata": {},
|
|
128
|
+
"outputs": [],
|
|
129
|
+
"source": [
|
|
130
|
+
"# Print the paths to the downloaded files\n",
|
|
131
|
+
"for band, path in downloaded_bands.items():\n",
|
|
132
|
+
" print(f\"Downloaded {band}: {path}\")"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"cell_type": "markdown",
|
|
137
|
+
"metadata": {},
|
|
138
|
+
"source": [
|
|
139
|
+
"## Visualize data"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"cell_type": "code",
|
|
144
|
+
"execution_count": null,
|
|
145
|
+
"metadata": {},
|
|
146
|
+
"outputs": [],
|
|
147
|
+
"source": [
|
|
148
|
+
"raster_url = \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/sentinel2a_kansas.tif\""
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"cell_type": "code",
|
|
153
|
+
"execution_count": null,
|
|
154
|
+
"metadata": {},
|
|
155
|
+
"outputs": [],
|
|
156
|
+
"source": [
|
|
157
|
+
"geoai.view_raster(raster_url, bidx=[8, 4, 3], rescale=\"1000,4000\")"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"metadata": {
|
|
162
|
+
"kernelspec": {
|
|
163
|
+
"display_name": "geo",
|
|
164
|
+
"language": "python",
|
|
165
|
+
"name": "python3"
|
|
166
|
+
},
|
|
167
|
+
"language_info": {
|
|
168
|
+
"codemirror_mode": {
|
|
169
|
+
"name": "ipython",
|
|
170
|
+
"version": 3
|
|
171
|
+
},
|
|
172
|
+
"file_extension": ".py",
|
|
173
|
+
"mimetype": "text/x-python",
|
|
174
|
+
"name": "python",
|
|
175
|
+
"nbconvert_exporter": "python",
|
|
176
|
+
"pygments_lexer": "ipython3",
|
|
177
|
+
"version": "3.12.9"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"nbformat": 4,
|
|
181
|
+
"nbformat_minor": 2
|
|
182
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Download Data from Planetary Computer\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/planetary_computer.ipynb)\n",
|
|
10
|
+
"\n",
|
|
11
|
+
"## Install package\n",
|
|
12
|
+
"To use the `geoai-py` package, ensure it is installed in your environment. Uncomment the command below if needed."
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"cell_type": "code",
|
|
17
|
+
"execution_count": null,
|
|
18
|
+
"metadata": {},
|
|
19
|
+
"outputs": [],
|
|
20
|
+
"source": [
|
|
21
|
+
"# %pip install geoai-py"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"cell_type": "markdown",
|
|
26
|
+
"metadata": {},
|
|
27
|
+
"source": [
|
|
28
|
+
"## Import libraries"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"cell_type": "code",
|
|
33
|
+
"execution_count": null,
|
|
34
|
+
"metadata": {},
|
|
35
|
+
"outputs": [],
|
|
36
|
+
"source": [
|
|
37
|
+
"import geoai"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"cell_type": "markdown",
|
|
42
|
+
"metadata": {},
|
|
43
|
+
"source": [
|
|
44
|
+
"## Retrieve collections"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"cell_type": "code",
|
|
49
|
+
"execution_count": null,
|
|
50
|
+
"metadata": {},
|
|
51
|
+
"outputs": [],
|
|
52
|
+
"source": [
|
|
53
|
+
"collections = geoai.pc_collection_list()\n",
|
|
54
|
+
"collections"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"cell_type": "markdown",
|
|
59
|
+
"metadata": {},
|
|
60
|
+
"source": [
|
|
61
|
+
"## Search data"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"cell_type": "code",
|
|
66
|
+
"execution_count": null,
|
|
67
|
+
"metadata": {},
|
|
68
|
+
"outputs": [],
|
|
69
|
+
"source": [
|
|
70
|
+
"items = geoai.pc_stac_search(\n",
|
|
71
|
+
" collection=\"naip\",\n",
|
|
72
|
+
" bbox=[-122.5, 47.2, -122.3, 47.4], # Seattle area\n",
|
|
73
|
+
" time_range=\"2023-01-01/2024-12-31\",\n",
|
|
74
|
+
" max_items=1,\n",
|
|
75
|
+
")"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"cell_type": "markdown",
|
|
80
|
+
"metadata": {},
|
|
81
|
+
"source": [
|
|
82
|
+
"## Download data"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"cell_type": "code",
|
|
87
|
+
"execution_count": null,
|
|
88
|
+
"metadata": {},
|
|
89
|
+
"outputs": [],
|
|
90
|
+
"source": [
|
|
91
|
+
"if items:\n",
|
|
92
|
+
" # Only download the visual imagery and thumbnail assets\n",
|
|
93
|
+
" downloaded = geoai.pc_stac_download(\n",
|
|
94
|
+
" items, output_dir=\"naip_data\", asset_keys=[\"image\", \"thumbnail\"], max_workers=3\n",
|
|
95
|
+
" )"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"metadata": {
|
|
100
|
+
"kernelspec": {
|
|
101
|
+
"display_name": "geo",
|
|
102
|
+
"language": "python",
|
|
103
|
+
"name": "python3"
|
|
104
|
+
},
|
|
105
|
+
"language_info": {
|
|
106
|
+
"codemirror_mode": {
|
|
107
|
+
"name": "ipython",
|
|
108
|
+
"version": 3
|
|
109
|
+
},
|
|
110
|
+
"file_extension": ".py",
|
|
111
|
+
"mimetype": "text/x-python",
|
|
112
|
+
"name": "python",
|
|
113
|
+
"nbconvert_exporter": "python",
|
|
114
|
+
"pygments_lexer": "ipython3",
|
|
115
|
+
"version": "3.12.9"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"nbformat": 4,
|
|
119
|
+
"nbformat_minor": 2
|
|
120
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Train a Building Footprints Detection Model for the USA\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/train_building_footprints_usa.ipynb)\n",
|
|
10
|
+
"\n",
|
|
11
|
+
"## Install package\n",
|
|
12
|
+
"To use the `geoai-py` package, ensure it is installed in your environment. Uncomment the command below if needed."
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"cell_type": "code",
|
|
17
|
+
"execution_count": null,
|
|
18
|
+
"metadata": {},
|
|
19
|
+
"outputs": [],
|
|
20
|
+
"source": [
|
|
21
|
+
"# %pip install geoai-py"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"cell_type": "markdown",
|
|
26
|
+
"metadata": {},
|
|
27
|
+
"source": [
|
|
28
|
+
"## Import libraries"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"cell_type": "code",
|
|
33
|
+
"execution_count": null,
|
|
34
|
+
"metadata": {},
|
|
35
|
+
"outputs": [],
|
|
36
|
+
"source": [
|
|
37
|
+
"import geoai"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"cell_type": "markdown",
|
|
42
|
+
"metadata": {},
|
|
43
|
+
"source": [
|
|
44
|
+
"## Download sample data"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"cell_type": "code",
|
|
49
|
+
"execution_count": null,
|
|
50
|
+
"metadata": {},
|
|
51
|
+
"outputs": [],
|
|
52
|
+
"source": [
|
|
53
|
+
"train_raster_url = (\n",
|
|
54
|
+
" \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/naip_rgb_train.tif\"\n",
|
|
55
|
+
")\n",
|
|
56
|
+
"train_vector_url = \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/naip_train_buildings.geojson\"\n",
|
|
57
|
+
"test_raster_url = (\n",
|
|
58
|
+
" \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/naip_test.tif\"\n",
|
|
59
|
+
")"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"cell_type": "code",
|
|
64
|
+
"execution_count": null,
|
|
65
|
+
"metadata": {},
|
|
66
|
+
"outputs": [],
|
|
67
|
+
"source": [
|
|
68
|
+
"train_raster_path = geoai.download_file(train_raster_url)\n",
|
|
69
|
+
"train_vector_path = geoai.download_file(train_vector_url)\n",
|
|
70
|
+
"test_raster_path = geoai.download_file(test_raster_url)"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"cell_type": "markdown",
|
|
75
|
+
"metadata": {},
|
|
76
|
+
"source": [
|
|
77
|
+
"## Visualize sample data"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"cell_type": "code",
|
|
82
|
+
"execution_count": null,
|
|
83
|
+
"metadata": {},
|
|
84
|
+
"outputs": [],
|
|
85
|
+
"source": [
|
|
86
|
+
"geoai.view_vector_interactive(train_vector_path, tiles=train_raster_url)"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"cell_type": "code",
|
|
91
|
+
"execution_count": null,
|
|
92
|
+
"metadata": {},
|
|
93
|
+
"outputs": [],
|
|
94
|
+
"source": [
|
|
95
|
+
"geoai.view_raster(test_raster_url)"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"cell_type": "markdown",
|
|
100
|
+
"metadata": {},
|
|
101
|
+
"source": [
|
|
102
|
+
"## Create training data"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"cell_type": "code",
|
|
107
|
+
"execution_count": null,
|
|
108
|
+
"metadata": {},
|
|
109
|
+
"outputs": [],
|
|
110
|
+
"source": [
|
|
111
|
+
"out_folder = \"output\"\n",
|
|
112
|
+
"tiles = geoai.export_geotiff_tiles(\n",
|
|
113
|
+
" in_raster=train_raster_path,\n",
|
|
114
|
+
" out_folder=out_folder,\n",
|
|
115
|
+
" in_class_data=train_vector_path,\n",
|
|
116
|
+
" tile_size=512,\n",
|
|
117
|
+
" stride=256,\n",
|
|
118
|
+
" buffer_radius=0,\n",
|
|
119
|
+
")"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"cell_type": "markdown",
|
|
124
|
+
"metadata": {},
|
|
125
|
+
"source": [
|
|
126
|
+
"## Train object detection model"
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"cell_type": "code",
|
|
131
|
+
"execution_count": null,
|
|
132
|
+
"metadata": {},
|
|
133
|
+
"outputs": [],
|
|
134
|
+
"source": [
|
|
135
|
+
"geoai.train_MaskRCNN_model(\n",
|
|
136
|
+
" images_dir=f\"{out_folder}/images\",\n",
|
|
137
|
+
" labels_dir=f\"{out_folder}/labels\",\n",
|
|
138
|
+
" output_dir=f\"{out_folder}/models\",\n",
|
|
139
|
+
" num_channels=3,\n",
|
|
140
|
+
" pretrained=True,\n",
|
|
141
|
+
" batch_size=4,\n",
|
|
142
|
+
" num_epochs=100,\n",
|
|
143
|
+
" learning_rate=0.005,\n",
|
|
144
|
+
" val_split=0.2,\n",
|
|
145
|
+
")"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"cell_type": "markdown",
|
|
150
|
+
"metadata": {},
|
|
151
|
+
"source": [
|
|
152
|
+
"## Run inference"
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"cell_type": "code",
|
|
157
|
+
"execution_count": null,
|
|
158
|
+
"metadata": {},
|
|
159
|
+
"outputs": [],
|
|
160
|
+
"source": [
|
|
161
|
+
"masks_path = \"naip_test_prediction.tif\"\n",
|
|
162
|
+
"model_path = f\"{out_folder}/models/building_footprints_usa.pth\""
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"cell_type": "code",
|
|
167
|
+
"execution_count": null,
|
|
168
|
+
"metadata": {},
|
|
169
|
+
"outputs": [],
|
|
170
|
+
"source": [
|
|
171
|
+
"geoai.object_detection(\n",
|
|
172
|
+
" test_raster_path,\n",
|
|
173
|
+
" masks_path,\n",
|
|
174
|
+
" model_path,\n",
|
|
175
|
+
" window_size=512,\n",
|
|
176
|
+
" overlap=256,\n",
|
|
177
|
+
" confidence_threshold=0.5,\n",
|
|
178
|
+
" batch_size=4,\n",
|
|
179
|
+
" num_channels=3,\n",
|
|
180
|
+
")"
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"cell_type": "markdown",
|
|
185
|
+
"metadata": {},
|
|
186
|
+
"source": [
|
|
187
|
+
"## Vectorize masks"
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"cell_type": "code",
|
|
192
|
+
"execution_count": null,
|
|
193
|
+
"metadata": {},
|
|
194
|
+
"outputs": [],
|
|
195
|
+
"source": [
|
|
196
|
+
"output_path = \"naip_test_prediction.geojson\"\n",
|
|
197
|
+
"gdf = geoai.orthogonalize(masks_path, output_path, epsilon=2)"
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"cell_type": "markdown",
|
|
202
|
+
"metadata": {},
|
|
203
|
+
"source": [
|
|
204
|
+
"## Visualize results"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"cell_type": "code",
|
|
209
|
+
"execution_count": null,
|
|
210
|
+
"metadata": {},
|
|
211
|
+
"outputs": [],
|
|
212
|
+
"source": [
|
|
213
|
+
"geoai.view_vector_interactive(output_path, tiles=test_raster_url)"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"cell_type": "code",
|
|
218
|
+
"execution_count": null,
|
|
219
|
+
"metadata": {},
|
|
220
|
+
"outputs": [],
|
|
221
|
+
"source": [
|
|
222
|
+
"geoai.create_split_map(\n",
|
|
223
|
+
" left_layer=output_path,\n",
|
|
224
|
+
" right_layer=test_raster_url,\n",
|
|
225
|
+
" left_args={\"style\": {\"color\": \"red\", \"fillOpacity\": 0.2}},\n",
|
|
226
|
+
" basemap=test_raster_url,\n",
|
|
227
|
+
")"
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"cell_type": "markdown",
|
|
232
|
+
"metadata": {},
|
|
233
|
+
"source": [
|
|
234
|
+
""
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
"metadata": {
|
|
239
|
+
"kernelspec": {
|
|
240
|
+
"display_name": "Python 3 (ipykernel)",
|
|
241
|
+
"language": "python",
|
|
242
|
+
"name": "python3"
|
|
243
|
+
},
|
|
244
|
+
"language_info": {
|
|
245
|
+
"codemirror_mode": {
|
|
246
|
+
"name": "ipython",
|
|
247
|
+
"version": 3
|
|
248
|
+
},
|
|
249
|
+
"file_extension": ".py",
|
|
250
|
+
"mimetype": "text/x-python",
|
|
251
|
+
"name": "python",
|
|
252
|
+
"nbconvert_exporter": "python",
|
|
253
|
+
"pygments_lexer": "ipython3",
|
|
254
|
+
"version": "3.12.9"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"nbformat": 4,
|
|
258
|
+
"nbformat_minor": 4
|
|
259
|
+
}
|