geoai-py 0.3.4__tar.gz → 0.3.6__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.3.6/.github/FUNDING.yml +3 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/PKG-INFO +5 -1
- {geoai_py-0.3.4 → geoai_py-0.3.6}/README.md +4 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/_template.ipynb +70 -0
- geoai_py-0.3.6/docs/examples/building_footprints_africa.ipynb +196 -0
- geoai_py-0.3.6/docs/examples/building_footprints_china.ipynb +196 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/car_detection.ipynb +16 -10
- geoai_py-0.3.6/docs/examples/ship_detection.ipynb +359 -0
- geoai_py-0.3.6/docs/examples/solar_panel_detection.ipynb +342 -0
- geoai_py-0.3.6/docs/examples/text_prompt_segmentation.ipynb +194 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/index.md +4 -0
- geoai_py-0.3.6/docs/segment.md +3 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai/__init__.py +1 -1
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai/extract.py +205 -104
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai/geoai.py +1 -0
- geoai_py-0.3.6/geoai/segment.py +305 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai/utils.py +861 -18
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai_py.egg-info/PKG-INFO +5 -1
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai_py.egg-info/SOURCES.txt +8 -1
- {geoai_py-0.3.4 → geoai_py-0.3.6}/mkdocs.yml +33 -16
- {geoai_py-0.3.4 → geoai_py-0.3.6}/pyproject.toml +2 -2
- {geoai_py-0.3.4 → geoai_py-0.3.6}/requirements_docs.txt +1 -1
- geoai_py-0.3.4/geoai/preprocess.py +0 -3021
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.editorconfig +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/dependabot.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/workflows/docs-build.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/workflows/docs.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/workflows/macos.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/workflows/pypi.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/workflows/ubuntu.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.github/workflows/windows.yml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.gitignore +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/.pre-commit-config.yaml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/LICENSE +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/MANIFEST.in +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/CNAME +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/changelog.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/contributing.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/download.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/building_footprints_usa.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/building_regularization.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/data_visualization.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/dataviz/lidar_viz.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/dataviz/raster_viz.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/dataviz/vector_viz.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/download_data.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/geometric_properties.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/image_chips.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/jupytext.toml +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/arcgis.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/box_prompts.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/fast_sam.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/input_prompts.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/satellite.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/text_prompts.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/examples/view_metadata.ipynb +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/extract.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/faq.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/geoai.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/installation.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/overrides/main.html +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/segmentation.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/usage.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/docs/utils.md +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai/download.py +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai/segmentation.py +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai_py.egg-info/dependency_links.txt +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai_py.egg-info/entry_points.txt +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai_py.egg-info/requires.txt +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/geoai_py.egg-info/top_level.txt +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/requirements.txt +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/setup.cfg +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/tests/__init__.py +0 -0
- {geoai_py-0.3.4 → geoai_py-0.3.6}/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.
|
|
3
|
+
Version: 0.3.6
|
|
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.
|
|
@@ -36,6 +36,76 @@
|
|
|
36
36
|
"source": [
|
|
37
37
|
"import geoai"
|
|
38
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
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"cell_type": "markdown",
|
|
56
|
+
"metadata": {},
|
|
57
|
+
"source": [
|
|
58
|
+
"## Visualize data"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"cell_type": "code",
|
|
63
|
+
"execution_count": null,
|
|
64
|
+
"metadata": {},
|
|
65
|
+
"outputs": [],
|
|
66
|
+
"source": []
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"cell_type": "markdown",
|
|
70
|
+
"metadata": {},
|
|
71
|
+
"source": [
|
|
72
|
+
"## Initialize model"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"cell_type": "code",
|
|
77
|
+
"execution_count": null,
|
|
78
|
+
"metadata": {},
|
|
79
|
+
"outputs": [],
|
|
80
|
+
"source": []
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"cell_type": "markdown",
|
|
84
|
+
"metadata": {},
|
|
85
|
+
"source": [
|
|
86
|
+
"## Run inference"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"cell_type": "code",
|
|
91
|
+
"execution_count": null,
|
|
92
|
+
"metadata": {},
|
|
93
|
+
"outputs": [],
|
|
94
|
+
"source": []
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"cell_type": "markdown",
|
|
98
|
+
"metadata": {},
|
|
99
|
+
"source": [
|
|
100
|
+
"## Visualize results"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"cell_type": "code",
|
|
105
|
+
"execution_count": null,
|
|
106
|
+
"metadata": {},
|
|
107
|
+
"outputs": [],
|
|
108
|
+
"source": []
|
|
39
109
|
}
|
|
40
110
|
],
|
|
41
111
|
"metadata": {
|
|
@@ -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
|
+
}
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"metadata": {},
|
|
80
80
|
"outputs": [],
|
|
81
81
|
"source": [
|
|
82
|
-
"
|
|
82
|
+
"geoai.view_raster(raster_url)"
|
|
83
83
|
]
|
|
84
84
|
},
|
|
85
85
|
{
|
|
@@ -116,9 +116,10 @@
|
|
|
116
116
|
"mask_path = detector.generate_masks(\n",
|
|
117
117
|
" raster_path=raster_path,\n",
|
|
118
118
|
" output_path=\"cars_masks.tif\",\n",
|
|
119
|
-
" confidence_threshold=0.
|
|
120
|
-
" mask_threshold=0.
|
|
119
|
+
" confidence_threshold=0.3,\n",
|
|
120
|
+
" mask_threshold=0.5,\n",
|
|
121
121
|
" overlap=0.25,\n",
|
|
122
|
+
" chip_size=(400, 400),\n",
|
|
122
123
|
")"
|
|
123
124
|
]
|
|
124
125
|
},
|
|
@@ -138,12 +139,8 @@
|
|
|
138
139
|
"gdf = detector.vectorize_masks(\n",
|
|
139
140
|
" masks_path=\"cars_masks.tif\",\n",
|
|
140
141
|
" output_path=\"cars.geojson\",\n",
|
|
141
|
-
" mask_threshold=127,\n",
|
|
142
142
|
" min_object_area=100,\n",
|
|
143
143
|
" max_object_area=2000,\n",
|
|
144
|
-
" erode_kernel_size=3,\n",
|
|
145
|
-
" erode_iterations=1,\n",
|
|
146
|
-
" use_watershed=True,\n",
|
|
147
144
|
")"
|
|
148
145
|
]
|
|
149
146
|
},
|
|
@@ -192,7 +189,9 @@
|
|
|
192
189
|
"metadata": {},
|
|
193
190
|
"outputs": [],
|
|
194
191
|
"source": [
|
|
195
|
-
"gdf_filter = gdf[
|
|
192
|
+
"gdf_filter = gdf[\n",
|
|
193
|
+
" (gdf[\"area_m2\"] > 8) & (gdf[\"area_m2\"] < 60) & (gdf[\"minor_length_m\"] > 1)\n",
|
|
194
|
+
"]"
|
|
196
195
|
]
|
|
197
196
|
},
|
|
198
197
|
{
|
|
@@ -228,11 +227,18 @@
|
|
|
228
227
|
"source": [
|
|
229
228
|
"geoai.view_vector_interactive(gdf_filter, tiles=raster_url)"
|
|
230
229
|
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"cell_type": "markdown",
|
|
233
|
+
"metadata": {},
|
|
234
|
+
"source": [
|
|
235
|
+
""
|
|
236
|
+
]
|
|
231
237
|
}
|
|
232
238
|
],
|
|
233
239
|
"metadata": {
|
|
234
240
|
"kernelspec": {
|
|
235
|
-
"display_name": "
|
|
241
|
+
"display_name": "torch",
|
|
236
242
|
"language": "python",
|
|
237
243
|
"name": "python3"
|
|
238
244
|
},
|
|
@@ -246,7 +252,7 @@
|
|
|
246
252
|
"name": "python",
|
|
247
253
|
"nbconvert_exporter": "python",
|
|
248
254
|
"pygments_lexer": "ipython3",
|
|
249
|
-
"version": "3.
|
|
255
|
+
"version": "3.11.8"
|
|
250
256
|
}
|
|
251
257
|
},
|
|
252
258
|
"nbformat": 4,
|