geoai-py 0.5.3__tar.gz → 0.5.4__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.
Files changed (106) hide show
  1. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/workflows/docs-build.yml +1 -0
  2. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/workflows/docs.yml +1 -0
  3. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/workflows/ubuntu.yml +2 -1
  4. {geoai_py-0.5.3 → geoai_py-0.5.4}/PKG-INFO +3 -3
  5. geoai_py-0.5.4/docs/examples/regularization.ipynb +185 -0
  6. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/__init__.py +1 -1
  7. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/utils.py +96 -0
  8. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai_py.egg-info/PKG-INFO +3 -3
  9. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai_py.egg-info/SOURCES.txt +1 -0
  10. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai_py.egg-info/requires.txt +1 -0
  11. {geoai_py-0.5.3 → geoai_py-0.5.4}/mkdocs.yml +10 -8
  12. {geoai_py-0.5.3 → geoai_py-0.5.4}/pyproject.toml +3 -4
  13. {geoai_py-0.5.3 → geoai_py-0.5.4}/requirements.txt +1 -0
  14. {geoai_py-0.5.3 → geoai_py-0.5.4}/.editorconfig +0 -0
  15. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/FUNDING.yml +0 -0
  16. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  17. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  18. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  19. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/dependabot.yml +0 -0
  20. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/workflows/macos.yml +0 -0
  21. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/workflows/pypi.yml +0 -0
  22. {geoai_py-0.5.3 → geoai_py-0.5.4}/.github/workflows/windows.yml +0 -0
  23. {geoai_py-0.5.3 → geoai_py-0.5.4}/.gitignore +0 -0
  24. {geoai_py-0.5.3 → geoai_py-0.5.4}/.pre-commit-config.yaml +0 -0
  25. {geoai_py-0.5.3 → geoai_py-0.5.4}/LICENSE +0 -0
  26. {geoai_py-0.5.3 → geoai_py-0.5.4}/MANIFEST.in +0 -0
  27. {geoai_py-0.5.3 → geoai_py-0.5.4}/README.md +0 -0
  28. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/CNAME +0 -0
  29. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/assets/logo.ico +0 -0
  30. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/assets/logo.png +0 -0
  31. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/assets/logo_rect.png +0 -0
  32. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/changelog.md +0 -0
  33. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/classify.md +0 -0
  34. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/contributing.md +0 -0
  35. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/download.md +0 -0
  36. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/_template.ipynb +0 -0
  37. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/building_footprints_africa.ipynb +0 -0
  38. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/building_footprints_china.ipynb +0 -0
  39. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/building_footprints_usa.ipynb +0 -0
  40. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/building_regularization.ipynb +0 -0
  41. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/car_detection.ipynb +0 -0
  42. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/create_vector.ipynb +0 -0
  43. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/data_visualization.ipynb +0 -0
  44. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/dataviz/lidar_viz.ipynb +0 -0
  45. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/dataviz/raster_viz.ipynb +0 -0
  46. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/dataviz/vector_viz.ipynb +0 -0
  47. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/download_data.ipynb +0 -0
  48. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/download_sentinel2.ipynb +0 -0
  49. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/edit_vector.ipynb +0 -0
  50. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/geometric_properties.ipynb +0 -0
  51. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/image_chips.ipynb +0 -0
  52. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/jupytext.toml +0 -0
  53. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/parking_spot_detection.ipynb +0 -0
  54. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/planetary_computer.ipynb +0 -0
  55. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
  56. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/arcgis.ipynb +0 -0
  57. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
  58. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
  59. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/box_prompts.ipynb +0 -0
  60. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/fast_sam.ipynb +0 -0
  61. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/input_prompts.ipynb +0 -0
  62. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
  63. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
  64. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
  65. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/satellite.ipynb +0 -0
  66. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
  67. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/text_prompts.ipynb +0 -0
  68. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
  69. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/ship_detection.ipynb +0 -0
  70. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/solar_panel_detection.ipynb +0 -0
  71. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/text_prompt_segmentation.ipynb +0 -0
  72. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/train_building_footprints_usa.ipynb +0 -0
  73. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/train_car_detection.ipynb +0 -0
  74. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/train_object_detection_model.ipynb +0 -0
  75. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/train_ship_detection.ipynb +0 -0
  76. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/train_solar_panel_detection.ipynb +0 -0
  77. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/train_water_detection.ipynb +0 -0
  78. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/view_metadata.ipynb +0 -0
  79. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/examples/wetland_mapping.ipynb +0 -0
  80. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/extract.md +0 -0
  81. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/faq.md +0 -0
  82. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/geoai.md +0 -0
  83. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/hf.md +0 -0
  84. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/index.md +0 -0
  85. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/installation.md +0 -0
  86. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/overrides/main.html +0 -0
  87. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/segment.md +0 -0
  88. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/segmentation.md +0 -0
  89. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/train.md +0 -0
  90. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/usage.md +0 -0
  91. {geoai_py-0.5.3 → geoai_py-0.5.4}/docs/utils.md +0 -0
  92. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/classify.py +0 -0
  93. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/download.py +0 -0
  94. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/extract.py +0 -0
  95. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/geoai.py +0 -0
  96. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/hf.py +0 -0
  97. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/segment.py +0 -0
  98. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/segmentation.py +0 -0
  99. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai/train.py +0 -0
  100. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai_py.egg-info/dependency_links.txt +0 -0
  101. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai_py.egg-info/entry_points.txt +0 -0
  102. {geoai_py-0.5.3 → geoai_py-0.5.4}/geoai_py.egg-info/top_level.txt +0 -0
  103. {geoai_py-0.5.3 → geoai_py-0.5.4}/requirements_docs.txt +0 -0
  104. {geoai_py-0.5.3 → geoai_py-0.5.4}/setup.cfg +0 -0
  105. {geoai_py-0.5.3 → geoai_py-0.5.4}/tests/__init__.py +0 -0
  106. {geoai_py-0.5.3 → geoai_py-0.5.4}/tests/test_geoai.py +0 -0
@@ -35,6 +35,7 @@ jobs:
35
35
  run: |
36
36
  uv pip install --find-links https://girder.github.io/large_image_wheels GDAL pyproj
37
37
  uv pip install pytest
38
+ uv pip install "geoai-py[extra]"
38
39
 
39
40
  - name: Test import
40
41
  run: |
@@ -34,6 +34,7 @@ jobs:
34
34
  run: |
35
35
  uv pip install --find-links https://girder.github.io/large_image_wheels GDAL pyproj
36
36
  uv pip install pytest
37
+ uv pip install "geoai-py[extra]"
37
38
 
38
39
  - name: Test import
39
40
  run: |
@@ -14,7 +14,7 @@ jobs:
14
14
  strategy:
15
15
  fail-fast: false
16
16
  matrix:
17
- python-version: ["3.9", "3.10", "3.11", "3.12"]
17
+ python-version: ["3.10", "3.11", "3.12"]
18
18
 
19
19
  steps:
20
20
  - uses: actions/checkout@v4
@@ -37,6 +37,7 @@ jobs:
37
37
  run: |
38
38
  uv pip install --find-links https://girder.github.io/large_image_wheels gdal pyproj
39
39
  uv pip install pytest
40
+ uv pip install "geoai-py[extra]"
40
41
 
41
42
  - name: Test import
42
43
  run: |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geoai-py
3
- Version: 0.5.3
3
+ Version: 0.5.4
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
@@ -9,15 +9,15 @@ Keywords: geoai
9
9
  Classifier: Intended Audience :: Developers
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Natural Language :: English
12
- Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
17
- Requires-Python: >=3.9
16
+ Requires-Python: >=3.10
18
17
  Description-Content-Type: text/markdown
19
18
  License-File: LICENSE
20
19
  Requires-Dist: albumentations
20
+ Requires-Dist: buildingregulariser
21
21
  Requires-Dist: contextily
22
22
  Requires-Dist: geopandas
23
23
  Requires-Dist: huggingface_hub
@@ -0,0 +1,185 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Regularization\n",
8
+ "\n",
9
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/regularization.ipynb)\n",
10
+ "\n",
11
+ "This example demonstrates how to regularize building footprints using the `regularize` function from the `geoai` package. The function is a wrapper around the `regularize_geodataframe` function from the [buildingregulariser](https://github.com/DPIRD-DMA/Building-Regulariser) package. Credits to the original author, Nick Wright.\n",
12
+ "\n",
13
+ "It can be used to regularize features such as building footprints, solar panels, cars, and other objects that have a regular shape.\n",
14
+ "\n",
15
+ "## Install package\n",
16
+ "To use the `geoai-py` package, ensure it is installed in your environment. Uncomment the command below if needed."
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "# %pip install geoai-py"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "markdown",
30
+ "metadata": {},
31
+ "source": [
32
+ "## Import libraries"
33
+ ]
34
+ },
35
+ {
36
+ "cell_type": "code",
37
+ "execution_count": null,
38
+ "metadata": {},
39
+ "outputs": [],
40
+ "source": [
41
+ "import geoai"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "markdown",
46
+ "metadata": {},
47
+ "source": [
48
+ "## Use sample data"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": null,
54
+ "metadata": {},
55
+ "outputs": [],
56
+ "source": [
57
+ "raster_url = (\n",
58
+ " \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/naip_train.tif\"\n",
59
+ ")\n",
60
+ "vector_url = \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/buildings_original.geojson\""
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "markdown",
65
+ "metadata": {},
66
+ "source": [
67
+ "## Visualize data"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "execution_count": null,
73
+ "metadata": {},
74
+ "outputs": [],
75
+ "source": [
76
+ "geoai.view_vector_interactive(vector_url, tiles=raster_url)"
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "markdown",
81
+ "metadata": {},
82
+ "source": [
83
+ "## Regularize buildings"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "code",
88
+ "execution_count": null,
89
+ "metadata": {},
90
+ "outputs": [],
91
+ "source": [
92
+ "gdf = geoai.regularize(\n",
93
+ " data=vector_url,\n",
94
+ " simplify_tolerance=2.0,\n",
95
+ " allow_45_degree=True,\n",
96
+ " diagonal_threshold_reduction=30,\n",
97
+ " allow_circles=True,\n",
98
+ " circle_threshold=0.9,\n",
99
+ ")"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": null,
105
+ "metadata": {},
106
+ "outputs": [],
107
+ "source": [
108
+ "geoai.view_vector_interactive(gdf, tiles=raster_url)"
109
+ ]
110
+ },
111
+ {
112
+ "cell_type": "code",
113
+ "execution_count": null,
114
+ "metadata": {},
115
+ "outputs": [],
116
+ "source": [
117
+ "geoai.create_split_map(\n",
118
+ " left_layer=gdf,\n",
119
+ " right_layer=raster_url,\n",
120
+ " left_label=\"Regularized Buildings\",\n",
121
+ " right_label=\"NAIP Imagery\",\n",
122
+ " left_args={\"style\": {\"color\": \"red\", \"fillOpacity\": 0.3}},\n",
123
+ " basemap=raster_url,\n",
124
+ ")"
125
+ ]
126
+ },
127
+ {
128
+ "cell_type": "markdown",
129
+ "metadata": {},
130
+ "source": [
131
+ "## Compare results"
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "code",
136
+ "execution_count": null,
137
+ "metadata": {},
138
+ "outputs": [],
139
+ "source": [
140
+ "import leafmap.foliumap as leafmap"
141
+ ]
142
+ },
143
+ {
144
+ "cell_type": "code",
145
+ "execution_count": null,
146
+ "metadata": {},
147
+ "outputs": [],
148
+ "source": [
149
+ "m = leafmap.Map()\n",
150
+ "m.add_cog_layer(raster_url, name=\"NAIP\")\n",
151
+ "m.add_vector(\n",
152
+ " vector_url, style={\"color\": \"yellow\", \"fillOpacity\": 0}, layer_name=\"Original\"\n",
153
+ ")\n",
154
+ "m.add_gdf(gdf, style={\"color\": \"red\", \"fillOpacity\": 0}, layer_name=\"Regularized\")\n",
155
+ "legend = {\n",
156
+ " \"Original\": \"yellow\",\n",
157
+ " \"Regularized\": \"red\",\n",
158
+ "}\n",
159
+ "m.add_legend(title=\"Building Footprints\", legend_dict=legend)\n",
160
+ "m"
161
+ ]
162
+ }
163
+ ],
164
+ "metadata": {
165
+ "kernelspec": {
166
+ "display_name": "geo",
167
+ "language": "python",
168
+ "name": "python3"
169
+ },
170
+ "language_info": {
171
+ "codemirror_mode": {
172
+ "name": "ipython",
173
+ "version": 3
174
+ },
175
+ "file_extension": ".py",
176
+ "mimetype": "text/x-python",
177
+ "name": "python",
178
+ "nbconvert_exporter": "python",
179
+ "pygments_lexer": "ipython3",
180
+ "version": "3.12.9"
181
+ }
182
+ },
183
+ "nbformat": 4,
184
+ "nbformat_minor": 2
185
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  __author__ = """Qiusheng Wu"""
4
4
  __email__ = "giswqs@gmail.com"
5
- __version__ = "0.5.3"
5
+ __version__ = "0.5.4"
6
6
 
7
7
 
8
8
  import os
@@ -6249,3 +6249,99 @@ def download_model_from_hf(model_path, repo_id=None):
6249
6249
  print(f"Error downloading model from Hugging Face: {e}")
6250
6250
  print("Please specify a local model path or ensure internet connectivity.")
6251
6251
  raise
6252
+
6253
+
6254
+ def regularize(
6255
+ data: Union[gpd.GeoDataFrame, str],
6256
+ parallel_threshold: float = 1.0,
6257
+ target_crs: Optional[Union[str, "pyproj.CRS"]] = None,
6258
+ simplify: bool = True,
6259
+ simplify_tolerance: float = 0.5,
6260
+ allow_45_degree: bool = True,
6261
+ diagonal_threshold_reduction: float = 15,
6262
+ allow_circles: bool = True,
6263
+ circle_threshold: float = 0.9,
6264
+ num_cores: int = 1,
6265
+ include_metadata: bool = False,
6266
+ output_path: Optional[str] = None,
6267
+ **kwargs,
6268
+ ) -> gpd.GeoDataFrame:
6269
+ """Regularizes polygon geometries in a GeoDataFrame by aligning edges.
6270
+
6271
+ Aligns edges to be parallel or perpendicular (optionally also 45 degrees)
6272
+ to their main direction. Handles reprojection, initial simplification,
6273
+ regularization, geometry cleanup, and parallel processing.
6274
+
6275
+ This function is a wrapper around the `regularize_geodataframe` function
6276
+ from the `buildingregulariser` package. Credits to the original author
6277
+ Nick Wright. Check out the repo at https://github.com/DPIRD-DMA/Building-Regulariser.
6278
+
6279
+ Args:
6280
+ data (Union[gpd.GeoDataFrame, str]): Input GeoDataFrame with polygon or multipolygon geometries,
6281
+ or a file path to the GeoDataFrame.
6282
+ parallel_threshold (float, optional): Distance threshold for merging nearly parallel adjacent edges
6283
+ during regularization. Defaults to 1.0.
6284
+ target_crs (Optional[Union[str, "pyproj.CRS"]], optional): Target Coordinate Reference System for
6285
+ processing. If None, uses the input GeoDataFrame's CRS. Processing is more reliable in a
6286
+ projected CRS. Defaults to None.
6287
+ simplify (bool, optional): If True, applies initial simplification to the geometry before
6288
+ regularization. Defaults to True.
6289
+ simplify_tolerance (float, optional): Tolerance for the initial simplification step (if `simplify`
6290
+ is True). Also used for geometry cleanup steps. Defaults to 0.5.
6291
+ allow_45_degree (bool, optional): If True, allows edges to be oriented at 45-degree angles relative
6292
+ to the main direction during regularization. Defaults to True.
6293
+ diagonal_threshold_reduction (float, optional): Reduction factor in degrees to reduce the likelihood
6294
+ of diagonal edges being created. Larger values reduce the likelihood of diagonal edges.
6295
+ Defaults to 15.
6296
+ allow_circles (bool, optional): If True, attempts to detect polygons that are nearly circular and
6297
+ replaces them with perfect circles. Defaults to True.
6298
+ circle_threshold (float, optional): Intersection over Union (IoU) threshold used for circle detection
6299
+ (if `allow_circles` is True). Value between 0 and 1. Defaults to 0.9.
6300
+ num_cores (int, optional): Number of CPU cores to use for parallel processing. If 1, processing is
6301
+ done sequentially. Defaults to 1.
6302
+ include_metadata (bool, optional): If True, includes metadata about the regularization process in the
6303
+ output GeoDataFrame. Defaults to False.
6304
+ output_path (Optional[str], optional): Path to save the output GeoDataFrame. If None, the output is
6305
+ not saved. Defaults to None.
6306
+ **kwargs: Additional keyword arguments to pass to the `to_file` method when saving the output.
6307
+
6308
+ Returns:
6309
+ gpd.GeoDataFrame: A new GeoDataFrame with regularized polygon geometries. Original attributes are
6310
+ preserved. Geometries that failed processing might be dropped.
6311
+
6312
+ Raises:
6313
+ ValueError: If the input data is not a GeoDataFrame or a file path, or if the input GeoDataFrame is empty.
6314
+ """
6315
+ try:
6316
+ from buildingregulariser import regularize_geodataframe
6317
+ except ImportError:
6318
+ install_package("buildingregulariser")
6319
+ from buildingregulariser import regularize_geodataframe
6320
+
6321
+ if isinstance(data, str):
6322
+ data = gpd.read_file(data)
6323
+ elif not isinstance(data, gpd.GeoDataFrame):
6324
+ raise ValueError("Input data must be a GeoDataFrame or a file path.")
6325
+
6326
+ # Check if the input data is empty
6327
+ if data.empty:
6328
+ raise ValueError("Input GeoDataFrame is empty.")
6329
+
6330
+ gdf = regularize_geodataframe(
6331
+ data,
6332
+ parallel_threshold=parallel_threshold,
6333
+ target_crs=target_crs,
6334
+ simplify=simplify,
6335
+ simplify_tolerance=simplify_tolerance,
6336
+ allow_45_degree=allow_45_degree,
6337
+ diagonal_threshold_reduction=diagonal_threshold_reduction,
6338
+ allow_circles=allow_circles,
6339
+ circle_threshold=circle_threshold,
6340
+ num_cores=num_cores,
6341
+ include_metadata=include_metadata,
6342
+ )
6343
+
6344
+ if output_path:
6345
+ gdf.to_file(output_path, **kwargs)
6346
+
6347
+ return gdf
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geoai-py
3
- Version: 0.5.3
3
+ Version: 0.5.4
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
@@ -9,15 +9,15 @@ Keywords: geoai
9
9
  Classifier: Intended Audience :: Developers
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Natural Language :: English
12
- Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
17
- Requires-Python: >=3.9
16
+ Requires-Python: >=3.10
18
17
  Description-Content-Type: text/markdown
19
18
  License-File: LICENSE
20
19
  Requires-Dist: albumentations
20
+ Requires-Dist: buildingregulariser
21
21
  Requires-Dist: contextily
22
22
  Requires-Dist: geopandas
23
23
  Requires-Dist: huggingface_hub
@@ -54,6 +54,7 @@ docs/examples/image_chips.ipynb
54
54
  docs/examples/jupytext.toml
55
55
  docs/examples/parking_spot_detection.ipynb
56
56
  docs/examples/planetary_computer.ipynb
57
+ docs/examples/regularization.ipynb
57
58
  docs/examples/ship_detection.ipynb
58
59
  docs/examples/solar_panel_detection.ipynb
59
60
  docs/examples/text_prompt_segmentation.ipynb
@@ -1,4 +1,5 @@
1
1
  albumentations
2
+ buildingregulariser
2
3
  contextily
3
4
  geopandas
4
5
  huggingface_hub
@@ -47,20 +47,21 @@ plugins:
47
47
  - mkdocs-jupyter:
48
48
  include_source: True
49
49
  ignore_h1_titles: True
50
- execute: false
50
+ execute: true
51
51
  allow_errors: false
52
52
  ignore: ["conf.py"]
53
- execute_ignore: [
53
+ execute_ignore:
54
+ [
54
55
  "examples/dataviz/*.ipynb",
55
56
  "examples/rastervision/*.ipynb",
56
57
  "examples/samgeo/*.ipynb",
58
+ "examples/download_*.ipynb",
59
+ "examples/planetary_computer.ipynb",
60
+ "examples/*_detection.ipynb",
61
+ "examples/building_footprints_*.ipynb",
57
62
  "examples/data_visualization.ipynb",
58
- "examples/download_data.ipynb",
59
- "examples/car_detection.ipynb",
60
- "examples/ship_detection.ipynb",
61
- # "examples/solar_panel_detection.ipynb",
62
- "examples/building_footprints_africa.ipynb",
63
- "examples/building_footprints_china.ipynb",
63
+ "examples/train_*.ipynb",
64
+ "examples/wetland_mapping.ipynb",
64
65
  ]
65
66
  # - mkdocstrings:
66
67
  # default_handler: python
@@ -124,6 +125,7 @@ nav:
124
125
  - examples/train_ship_detection.ipynb
125
126
  - examples/train_water_detection.ipynb
126
127
  - examples/wetland_mapping.ipynb
128
+ - examples/regularization.ipynb
127
129
  # - examples/samgeo/satellite.ipynb
128
130
  # - examples/samgeo/automatic_mask_generator.ipynb
129
131
  # - examples/samgeo/automatic_mask_generator_hq.ipynb
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "geoai-py"
3
- version = "0.5.3"
3
+ version = "0.5.4"
4
4
  dynamic = [
5
5
  "dependencies",
6
6
  ]
7
7
  description = "A Python package for using Artificial Intelligence (AI) with geospatial data"
8
8
  readme = "README.md"
9
- requires-python = ">=3.9"
9
+ requires-python = ">=3.10"
10
10
  keywords = [
11
11
  "geoai",
12
12
  ]
@@ -18,7 +18,6 @@ classifiers = [
18
18
  "Intended Audience :: Developers",
19
19
  "License :: OSI Approved :: MIT License",
20
20
  "Natural Language :: English",
21
- "Programming Language :: Python :: 3.9",
22
21
  "Programming Language :: Python :: 3.10",
23
22
  "Programming Language :: Python :: 3.11",
24
23
  "Programming Language :: Python :: 3.12",
@@ -44,7 +43,7 @@ universal = true
44
43
 
45
44
 
46
45
  [tool.bumpversion]
47
- current_version = "0.5.3"
46
+ current_version = "0.5.4"
48
47
  commit = true
49
48
  tag = true
50
49
 
@@ -1,4 +1,5 @@
1
1
  albumentations
2
+ buildingregulariser
2
3
  contextily
3
4
  geopandas
4
5
  huggingface_hub
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
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
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