geoai-py 0.3.5__tar.gz → 0.4.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.
- geoai_py-0.4.0/.github/FUNDING.yml +3 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.gitignore +1 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/PKG-INFO +5 -1
- {geoai_py-0.3.5 → geoai_py-0.4.0}/README.md +4 -0
- geoai_py-0.4.0/docs/examples/building_footprints_africa.ipynb +196 -0
- geoai_py-0.4.0/docs/examples/building_footprints_china.ipynb +196 -0
- geoai_py-0.4.0/docs/examples/parking_spot_detection.ipynb +203 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/ship_detection.ipynb +1 -0
- geoai_py-0.4.0/docs/examples/solar_panel_detection.ipynb +342 -0
- geoai_py-0.4.0/docs/examples/text_prompt_segmentation.ipynb +194 -0
- geoai_py-0.4.0/docs/examples/train_object_detection_model.ipynb +259 -0
- geoai_py-0.4.0/docs/hf.md +3 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/index.md +4 -0
- geoai_py-0.4.0/docs/segment.md +3 -0
- geoai_py-0.4.0/docs/train.md +3 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai/__init__.py +1 -1
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai/download.py +9 -8
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai/extract.py +158 -38
- geoai_py-0.4.0/geoai/geoai.py +7 -0
- geoai_py-0.4.0/geoai/hf.py +447 -0
- geoai_py-0.4.0/geoai/segment.py +306 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai/segmentation.py +8 -7
- geoai_py-0.4.0/geoai/train.py +1039 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai/utils.py +863 -25
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai_py.egg-info/PKG-INFO +5 -1
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai_py.egg-info/SOURCES.txt +13 -1
- {geoai_py-0.3.5 → geoai_py-0.4.0}/mkdocs.yml +35 -17
- {geoai_py-0.3.5 → geoai_py-0.4.0}/pyproject.toml +2 -2
- {geoai_py-0.3.5 → geoai_py-0.4.0}/requirements_docs.txt +2 -1
- geoai_py-0.3.5/geoai/geoai.py +0 -4
- geoai_py-0.3.5/geoai/preprocess.py +0 -3021
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.editorconfig +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/dependabot.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/workflows/docs-build.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/workflows/docs.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/workflows/macos.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/workflows/pypi.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/workflows/ubuntu.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.github/workflows/windows.yml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/.pre-commit-config.yaml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/LICENSE +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/MANIFEST.in +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/CNAME +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/changelog.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/contributing.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/download.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/_template.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/building_footprints_usa.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/building_regularization.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/car_detection.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/data_visualization.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/dataviz/lidar_viz.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/dataviz/raster_viz.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/dataviz/vector_viz.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/download_data.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/geometric_properties.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/image_chips.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/jupytext.toml +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/arcgis.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/box_prompts.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/fast_sam.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/input_prompts.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/satellite.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/text_prompts.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/examples/view_metadata.ipynb +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/extract.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/faq.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/geoai.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/installation.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/overrides/main.html +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/segmentation.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/usage.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/docs/utils.md +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai_py.egg-info/dependency_links.txt +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai_py.egg-info/entry_points.txt +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai_py.egg-info/requires.txt +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/geoai_py.egg-info/top_level.txt +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/requirements.txt +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/setup.cfg +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/tests/__init__.py +0 -0
- {geoai_py-0.3.5 → geoai_py-0.4.0}/tests/test_geoai.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: geoai-py
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
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
|
|
@@ -144,3 +144,7 @@ We welcome contributions of all kinds! See our [contributing guide](https://geoa
|
|
|
144
144
|
## 📄 License
|
|
145
145
|
|
|
146
146
|
GeoAI is free and open source software, licensed under the MIT License.
|
|
147
|
+
|
|
148
|
+
## 💖 Acknowledgment
|
|
149
|
+
|
|
150
|
+
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.
|
|
@@ -98,3 +98,7 @@ We welcome contributions of all kinds! See our [contributing guide](https://geoa
|
|
|
98
98
|
## 📄 License
|
|
99
99
|
|
|
100
100
|
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.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Building Footprint Extraction for Africa\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/building_footprints_africa.ipynb)\n",
|
|
10
|
+
"\n",
|
|
11
|
+
"## Install package\n",
|
|
12
|
+
"\n",
|
|
13
|
+
"To use the `geoai-py` package, ensure it is installed in your environment. Uncomment the command below if needed."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"cell_type": "code",
|
|
18
|
+
"execution_count": null,
|
|
19
|
+
"metadata": {},
|
|
20
|
+
"outputs": [],
|
|
21
|
+
"source": [
|
|
22
|
+
"# %pip install geoai-py"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"cell_type": "markdown",
|
|
27
|
+
"metadata": {},
|
|
28
|
+
"source": [
|
|
29
|
+
"## Import libraries"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"cell_type": "code",
|
|
34
|
+
"execution_count": null,
|
|
35
|
+
"metadata": {},
|
|
36
|
+
"outputs": [],
|
|
37
|
+
"source": [
|
|
38
|
+
"import geoai"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"cell_type": "markdown",
|
|
43
|
+
"metadata": {},
|
|
44
|
+
"source": [
|
|
45
|
+
"## Download sample data"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"cell_type": "code",
|
|
50
|
+
"execution_count": null,
|
|
51
|
+
"metadata": {},
|
|
52
|
+
"outputs": [],
|
|
53
|
+
"source": [
|
|
54
|
+
"raster_url = \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/buildings_africa.tif\""
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"cell_type": "code",
|
|
59
|
+
"execution_count": null,
|
|
60
|
+
"metadata": {},
|
|
61
|
+
"outputs": [],
|
|
62
|
+
"source": [
|
|
63
|
+
"raster_path = geoai.download_file(raster_url)"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"cell_type": "markdown",
|
|
68
|
+
"metadata": {},
|
|
69
|
+
"source": [
|
|
70
|
+
"## Initialize the model"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"cell_type": "code",
|
|
75
|
+
"execution_count": null,
|
|
76
|
+
"metadata": {},
|
|
77
|
+
"outputs": [],
|
|
78
|
+
"source": [
|
|
79
|
+
"extractor = geoai.BuildingFootprintExtractor(\n",
|
|
80
|
+
" model_path=\"building_footprints_africa.pth\"\n",
|
|
81
|
+
")"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"cell_type": "markdown",
|
|
86
|
+
"metadata": {},
|
|
87
|
+
"source": [
|
|
88
|
+
"## Extract building footprints"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"cell_type": "code",
|
|
93
|
+
"execution_count": null,
|
|
94
|
+
"metadata": {},
|
|
95
|
+
"outputs": [],
|
|
96
|
+
"source": [
|
|
97
|
+
"masks_path = extractor.generate_masks(\n",
|
|
98
|
+
" raster_path,\n",
|
|
99
|
+
" output_dir=\"building_masks.tif\",\n",
|
|
100
|
+
" min_object_area=1000,\n",
|
|
101
|
+
" confidence_threshold=0.5,\n",
|
|
102
|
+
" threshold=0.5,\n",
|
|
103
|
+
")"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"cell_type": "code",
|
|
108
|
+
"execution_count": null,
|
|
109
|
+
"metadata": {},
|
|
110
|
+
"outputs": [],
|
|
111
|
+
"source": [
|
|
112
|
+
"geoai.view_raster(masks_path, opacity=0.7, colormap=\"tab20\", basemap=raster_url)"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"cell_type": "markdown",
|
|
117
|
+
"metadata": {},
|
|
118
|
+
"source": [
|
|
119
|
+
"## Vectorize masks"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"cell_type": "code",
|
|
124
|
+
"execution_count": null,
|
|
125
|
+
"metadata": {},
|
|
126
|
+
"outputs": [],
|
|
127
|
+
"source": [
|
|
128
|
+
"gdf = geoai.orthogonalize(\n",
|
|
129
|
+
" input_path=masks_path, output_path=\"building_footprints.geojson\", epsilon=1.0\n",
|
|
130
|
+
")"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"cell_type": "markdown",
|
|
135
|
+
"metadata": {},
|
|
136
|
+
"source": [
|
|
137
|
+
"## Add geometric attributes"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"cell_type": "code",
|
|
142
|
+
"execution_count": null,
|
|
143
|
+
"metadata": {},
|
|
144
|
+
"outputs": [],
|
|
145
|
+
"source": [
|
|
146
|
+
"gdf = geoai.add_geometric_properties(gdf)"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"cell_type": "markdown",
|
|
151
|
+
"metadata": {},
|
|
152
|
+
"source": [
|
|
153
|
+
"## Visualize results"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"cell_type": "code",
|
|
158
|
+
"execution_count": null,
|
|
159
|
+
"metadata": {},
|
|
160
|
+
"outputs": [],
|
|
161
|
+
"source": [
|
|
162
|
+
"geoai.view_vector_interactive(\n",
|
|
163
|
+
" gdf, style_kwds={\"color\": \"red\", \"fillOpacity\": 0.2}, tiles=raster_url\n",
|
|
164
|
+
")"
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"cell_type": "markdown",
|
|
169
|
+
"metadata": {},
|
|
170
|
+
"source": [
|
|
171
|
+
""
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"metadata": {
|
|
176
|
+
"kernelspec": {
|
|
177
|
+
"display_name": "geo",
|
|
178
|
+
"language": "python",
|
|
179
|
+
"name": "python3"
|
|
180
|
+
},
|
|
181
|
+
"language_info": {
|
|
182
|
+
"codemirror_mode": {
|
|
183
|
+
"name": "ipython",
|
|
184
|
+
"version": 3
|
|
185
|
+
},
|
|
186
|
+
"file_extension": ".py",
|
|
187
|
+
"mimetype": "text/x-python",
|
|
188
|
+
"name": "python",
|
|
189
|
+
"nbconvert_exporter": "python",
|
|
190
|
+
"pygments_lexer": "ipython3",
|
|
191
|
+
"version": "3.12.9"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"nbformat": 4,
|
|
195
|
+
"nbformat_minor": 2
|
|
196
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Building Footprint Extraction for China\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/building_footprints_china.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
|
+
"raster_url = (\n",
|
|
54
|
+
" \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/buildings_china.tif\"\n",
|
|
55
|
+
")"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"cell_type": "code",
|
|
60
|
+
"execution_count": null,
|
|
61
|
+
"metadata": {},
|
|
62
|
+
"outputs": [],
|
|
63
|
+
"source": [
|
|
64
|
+
"raster_path = geoai.download_file(raster_url)"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"cell_type": "markdown",
|
|
69
|
+
"metadata": {},
|
|
70
|
+
"source": [
|
|
71
|
+
"## Initialize the model"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"cell_type": "code",
|
|
76
|
+
"execution_count": null,
|
|
77
|
+
"metadata": {},
|
|
78
|
+
"outputs": [],
|
|
79
|
+
"source": [
|
|
80
|
+
"extractor = geoai.BuildingFootprintExtractor(model_path=\"building_footprints_china.pth\")"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"cell_type": "markdown",
|
|
85
|
+
"metadata": {},
|
|
86
|
+
"source": [
|
|
87
|
+
"## Extract building footprints"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"cell_type": "code",
|
|
92
|
+
"execution_count": null,
|
|
93
|
+
"metadata": {},
|
|
94
|
+
"outputs": [],
|
|
95
|
+
"source": [
|
|
96
|
+
"masks_path = extractor.generate_masks(\n",
|
|
97
|
+
" raster_path,\n",
|
|
98
|
+
" output_dir=\"building_masks.tif\",\n",
|
|
99
|
+
" min_object_area=1000,\n",
|
|
100
|
+
" confidence_threshold=0.5,\n",
|
|
101
|
+
" mask_threshold=0.6,\n",
|
|
102
|
+
" threshold=0.5,\n",
|
|
103
|
+
")"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"cell_type": "code",
|
|
108
|
+
"execution_count": null,
|
|
109
|
+
"metadata": {},
|
|
110
|
+
"outputs": [],
|
|
111
|
+
"source": [
|
|
112
|
+
"geoai.view_raster(masks_path, opacity=0.7, colormap=\"tab20\", basemap=raster_path)"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"cell_type": "markdown",
|
|
117
|
+
"metadata": {},
|
|
118
|
+
"source": [
|
|
119
|
+
"## Vectorize masks"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"cell_type": "code",
|
|
124
|
+
"execution_count": null,
|
|
125
|
+
"metadata": {},
|
|
126
|
+
"outputs": [],
|
|
127
|
+
"source": [
|
|
128
|
+
"gdf = geoai.orthogonalize(\n",
|
|
129
|
+
" input_path=masks_path, output_path=\"building_footprints.geojson\", epsilon=1.0\n",
|
|
130
|
+
")"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"cell_type": "markdown",
|
|
135
|
+
"metadata": {},
|
|
136
|
+
"source": [
|
|
137
|
+
"## Add geometric attributes"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"cell_type": "code",
|
|
142
|
+
"execution_count": null,
|
|
143
|
+
"metadata": {},
|
|
144
|
+
"outputs": [],
|
|
145
|
+
"source": [
|
|
146
|
+
"gdf = geoai.add_geometric_properties(gdf)"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"cell_type": "markdown",
|
|
151
|
+
"metadata": {},
|
|
152
|
+
"source": [
|
|
153
|
+
"## Visualize results"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"cell_type": "code",
|
|
158
|
+
"execution_count": null,
|
|
159
|
+
"metadata": {},
|
|
160
|
+
"outputs": [],
|
|
161
|
+
"source": [
|
|
162
|
+
"geoai.view_vector_interactive(\n",
|
|
163
|
+
" gdf, style_kwds={\"color\": \"red\", \"fillOpacity\": 0.4}, tiles=raster_url\n",
|
|
164
|
+
")"
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"cell_type": "markdown",
|
|
169
|
+
"metadata": {},
|
|
170
|
+
"source": [
|
|
171
|
+
""
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"metadata": {
|
|
176
|
+
"kernelspec": {
|
|
177
|
+
"display_name": "geo",
|
|
178
|
+
"language": "python",
|
|
179
|
+
"name": "python3"
|
|
180
|
+
},
|
|
181
|
+
"language_info": {
|
|
182
|
+
"codemirror_mode": {
|
|
183
|
+
"name": "ipython",
|
|
184
|
+
"version": 3
|
|
185
|
+
},
|
|
186
|
+
"file_extension": ".py",
|
|
187
|
+
"mimetype": "text/x-python",
|
|
188
|
+
"name": "python",
|
|
189
|
+
"nbconvert_exporter": "python",
|
|
190
|
+
"pygments_lexer": "ipython3",
|
|
191
|
+
"version": "3.12.9"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"nbformat": 4,
|
|
195
|
+
"nbformat_minor": 2
|
|
196
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Parking Spot Detection\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/parking_spot_detection.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\n",
|
|
45
|
+
"\n",
|
|
46
|
+
"We will download a sample image from Hugging Face Hub to use for parking spot detection. You can find more high-resolution images from [OpenAerialMap](https://openaerialmap.org)."
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"cell_type": "code",
|
|
51
|
+
"execution_count": null,
|
|
52
|
+
"metadata": {},
|
|
53
|
+
"outputs": [],
|
|
54
|
+
"source": [
|
|
55
|
+
"raster_url = (\n",
|
|
56
|
+
" \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/parking_spots.tif\"\n",
|
|
57
|
+
")"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"cell_type": "code",
|
|
62
|
+
"execution_count": null,
|
|
63
|
+
"metadata": {},
|
|
64
|
+
"outputs": [],
|
|
65
|
+
"source": [
|
|
66
|
+
"raster_path = geoai.download_file(raster_url)"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"cell_type": "markdown",
|
|
71
|
+
"metadata": {},
|
|
72
|
+
"source": [
|
|
73
|
+
"## Visualize the image"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"cell_type": "code",
|
|
78
|
+
"execution_count": null,
|
|
79
|
+
"metadata": {},
|
|
80
|
+
"outputs": [],
|
|
81
|
+
"source": [
|
|
82
|
+
"geoai.view_raster(raster_url)"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"cell_type": "markdown",
|
|
87
|
+
"metadata": {},
|
|
88
|
+
"source": [
|
|
89
|
+
"## Initialize the model"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"cell_type": "code",
|
|
94
|
+
"execution_count": null,
|
|
95
|
+
"metadata": {},
|
|
96
|
+
"outputs": [],
|
|
97
|
+
"source": [
|
|
98
|
+
"detector = geoai.ParkingSplotDetector()"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"cell_type": "markdown",
|
|
103
|
+
"metadata": {},
|
|
104
|
+
"source": [
|
|
105
|
+
"## Extract parking spots\n",
|
|
106
|
+
"\n",
|
|
107
|
+
"Extract parking spots from the image using the model and save the output image."
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"cell_type": "code",
|
|
112
|
+
"execution_count": null,
|
|
113
|
+
"metadata": {},
|
|
114
|
+
"outputs": [],
|
|
115
|
+
"source": [
|
|
116
|
+
"mask_path = detector.generate_masks(\n",
|
|
117
|
+
" raster_path=raster_path,\n",
|
|
118
|
+
" output_path=\"parking_masks.tif\",\n",
|
|
119
|
+
" confidence_threshold=0.5,\n",
|
|
120
|
+
" mask_threshold=0.5,\n",
|
|
121
|
+
" overlap=0.25,\n",
|
|
122
|
+
" chip_size=(256, 256),\n",
|
|
123
|
+
" min_object_area=10,\n",
|
|
124
|
+
" # max_object_area=5000,\n",
|
|
125
|
+
")"
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"cell_type": "markdown",
|
|
130
|
+
"metadata": {},
|
|
131
|
+
"source": [
|
|
132
|
+
"Convert the image masks to polygons and save the output GeoJSON file."
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"cell_type": "code",
|
|
137
|
+
"execution_count": null,
|
|
138
|
+
"metadata": {},
|
|
139
|
+
"outputs": [],
|
|
140
|
+
"source": [
|
|
141
|
+
"gdf = detector.vectorize_masks(\n",
|
|
142
|
+
" masks_path=\"parking_masks.tif\",\n",
|
|
143
|
+
" output_path=\"parking.geojson\",\n",
|
|
144
|
+
" min_object_area=300,\n",
|
|
145
|
+
" # max_object_area=5000,\n",
|
|
146
|
+
")"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"cell_type": "markdown",
|
|
151
|
+
"metadata": {},
|
|
152
|
+
"source": [
|
|
153
|
+
"## Add geometric properties"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"cell_type": "code",
|
|
158
|
+
"execution_count": null,
|
|
159
|
+
"metadata": {},
|
|
160
|
+
"outputs": [],
|
|
161
|
+
"source": [
|
|
162
|
+
"gdf = geoai.add_geometric_properties(gdf)"
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"cell_type": "markdown",
|
|
167
|
+
"metadata": {},
|
|
168
|
+
"source": [
|
|
169
|
+
"## Visualize results"
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"cell_type": "code",
|
|
174
|
+
"execution_count": null,
|
|
175
|
+
"metadata": {},
|
|
176
|
+
"outputs": [],
|
|
177
|
+
"source": [
|
|
178
|
+
"geoai.view_vector_interactive(gdf, column=\"confidence\", tiles=raster_url)"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"metadata": {
|
|
183
|
+
"kernelspec": {
|
|
184
|
+
"display_name": "geo",
|
|
185
|
+
"language": "python",
|
|
186
|
+
"name": "python3"
|
|
187
|
+
},
|
|
188
|
+
"language_info": {
|
|
189
|
+
"codemirror_mode": {
|
|
190
|
+
"name": "ipython",
|
|
191
|
+
"version": 3
|
|
192
|
+
},
|
|
193
|
+
"file_extension": ".py",
|
|
194
|
+
"mimetype": "text/x-python",
|
|
195
|
+
"name": "python",
|
|
196
|
+
"nbconvert_exporter": "python",
|
|
197
|
+
"pygments_lexer": "ipython3",
|
|
198
|
+
"version": "3.12.9"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"nbformat": 4,
|
|
202
|
+
"nbformat_minor": 2
|
|
203
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"# Ship Detection\n",
|
|
8
8
|
"\n",
|
|
9
9
|
"This notebook demonstrates how to use the geoai package for ship detection using a pre-trained model. \n",
|
|
10
|
+
"\n",
|
|
10
11
|
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/ship_detection.ipynb)\n",
|
|
11
12
|
"\n",
|
|
12
13
|
"## Install package\n",
|