geoai-py 0.5.3__py2.py3-none-any.whl → 0.5.4__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geoai/__init__.py +1 -1
- geoai/utils.py +96 -0
- {geoai_py-0.5.3.dist-info → geoai_py-0.5.4.dist-info}/METADATA +3 -3
- {geoai_py-0.5.3.dist-info → geoai_py-0.5.4.dist-info}/RECORD +8 -8
- {geoai_py-0.5.3.dist-info → geoai_py-0.5.4.dist-info}/WHEEL +0 -0
- {geoai_py-0.5.3.dist-info → geoai_py-0.5.4.dist-info}/entry_points.txt +0 -0
- {geoai_py-0.5.3.dist-info → geoai_py-0.5.4.dist-info}/licenses/LICENSE +0 -0
- {geoai_py-0.5.3.dist-info → geoai_py-0.5.4.dist-info}/top_level.txt +0 -0
geoai/__init__.py
CHANGED
geoai/utils.py
CHANGED
|
@@ -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
|
+
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.
|
|
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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
geoai/__init__.py,sha256=
|
|
1
|
+
geoai/__init__.py,sha256=_SUkF87skch6o0kWnBmcY5ki_cjE1uSsIVM_ByCU6eA,3765
|
|
2
2
|
geoai/classify.py,sha256=_e-193QzAx3pIxUflPIsIs1qZevQx5ADu7i3bOL1G70,35055
|
|
3
3
|
geoai/download.py,sha256=lJ1GsJOZsKc2i6_dQyPV-XXIXmlADOpmSBo-wha4DEU,40892
|
|
4
4
|
geoai/extract.py,sha256=GocJufMmrwEWxNBL1J91EXXHL8AKcO8m_lmtUF5AKPw,119102
|
|
@@ -7,10 +7,10 @@ geoai/hf.py,sha256=mLKGxEAS5eHkxZLwuLpYc1o7e3-7QIXdBv-QUY-RkFk,17072
|
|
|
7
7
|
geoai/segment.py,sha256=g3YW17ftr--CKq6VB32TJEPY8owGQ7uQ0sg_tUT2ooE,13681
|
|
8
8
|
geoai/segmentation.py,sha256=AtPzCvguHAEeuyXafa4bzMFATvltEYcah1B8ZMfkM_s,11373
|
|
9
9
|
geoai/train.py,sha256=mQXat2yuddT-2rME4xnX_m3SkY23E_-zdxLnBIKxw8o,44091
|
|
10
|
-
geoai/utils.py,sha256=
|
|
11
|
-
geoai_py-0.5.
|
|
12
|
-
geoai_py-0.5.
|
|
13
|
-
geoai_py-0.5.
|
|
14
|
-
geoai_py-0.5.
|
|
15
|
-
geoai_py-0.5.
|
|
16
|
-
geoai_py-0.5.
|
|
10
|
+
geoai/utils.py,sha256=075-CoiYIYs7ZgtWOnyw5pBaQIeWuBW49JwTYfOBHDI,244386
|
|
11
|
+
geoai_py-0.5.4.dist-info/licenses/LICENSE,sha256=vN2L5U7cZ6ZkOHFmc8WiGlsogWsZc5dllMeNxnKVOZg,1070
|
|
12
|
+
geoai_py-0.5.4.dist-info/METADATA,sha256=aCOkYuGkhV6Iuzv5o5RvJNhAMApwANK9aJqmgPWG6y4,6623
|
|
13
|
+
geoai_py-0.5.4.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
|
14
|
+
geoai_py-0.5.4.dist-info/entry_points.txt,sha256=uGp3Az3HURIsRHP9v-ys0hIbUuBBNUfXv6VbYHIXeg4,41
|
|
15
|
+
geoai_py-0.5.4.dist-info/top_level.txt,sha256=1YkCUWu-ii-0qIex7kbwAvfei-gos9ycyDyUCJPNWHY,6
|
|
16
|
+
geoai_py-0.5.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|