geoai-py 0.3.1__py2.py3-none-any.whl → 0.3.3__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/extract.py +275 -143
- geoai/geoai.py +0 -1
- geoai/preprocess.py +20 -6
- geoai/utils.py +3882 -13
- {geoai_py-0.3.1.dist-info → geoai_py-0.3.3.dist-info}/METADATA +11 -5
- geoai_py-0.3.3.dist-info/RECORD +13 -0
- geoai_py-0.3.1.dist-info/RECORD +0 -13
- {geoai_py-0.3.1.dist-info → geoai_py-0.3.3.dist-info}/LICENSE +0 -0
- {geoai_py-0.3.1.dist-info → geoai_py-0.3.3.dist-info}/WHEEL +0 -0
- {geoai_py-0.3.1.dist-info → geoai_py-0.3.3.dist-info}/entry_points.txt +0 -0
- {geoai_py-0.3.1.dist-info → geoai_py-0.3.3.dist-info}/top_level.txt +0 -0
geoai/geoai.py
CHANGED
geoai/preprocess.py
CHANGED
|
@@ -288,7 +288,11 @@ def get_vector_info(vector_path):
|
|
|
288
288
|
dict: Dictionary containing the basic information about the vector dataset
|
|
289
289
|
"""
|
|
290
290
|
# Open the vector dataset
|
|
291
|
-
gdf =
|
|
291
|
+
gdf = (
|
|
292
|
+
gpd.read_parquet(vector_path)
|
|
293
|
+
if vector_path.endswith(".parquet")
|
|
294
|
+
else gpd.read_file(vector_path)
|
|
295
|
+
)
|
|
292
296
|
|
|
293
297
|
# Get basic metadata
|
|
294
298
|
info = {
|
|
@@ -359,7 +363,11 @@ def print_vector_info(vector_path, show_preview=True, figsize=(10, 8)):
|
|
|
359
363
|
|
|
360
364
|
# Show a preview if requested
|
|
361
365
|
if show_preview:
|
|
362
|
-
gdf =
|
|
366
|
+
gdf = (
|
|
367
|
+
gpd.read_parquet(vector_path)
|
|
368
|
+
if vector_path.endswith(".parquet")
|
|
369
|
+
else gpd.read_file(vector_path)
|
|
370
|
+
)
|
|
363
371
|
fig, ax = plt.subplots(figsize=figsize)
|
|
364
372
|
gdf.plot(ax=ax, cmap="viridis")
|
|
365
373
|
ax.set_title(f"Preview: {vector_path}")
|
|
@@ -2813,7 +2821,8 @@ def masks_to_vector(
|
|
|
2813
2821
|
output_path=None,
|
|
2814
2822
|
simplify_tolerance=1.0,
|
|
2815
2823
|
mask_threshold=0.5,
|
|
2816
|
-
|
|
2824
|
+
min_object_area=100,
|
|
2825
|
+
max_object_area=None,
|
|
2817
2826
|
nms_iou_threshold=0.5,
|
|
2818
2827
|
):
|
|
2819
2828
|
"""
|
|
@@ -2824,7 +2833,8 @@ def masks_to_vector(
|
|
|
2824
2833
|
output_path: Path to save the output GeoJSON (default: mask_path with .geojson extension)
|
|
2825
2834
|
simplify_tolerance: Tolerance for polygon simplification (default: self.simplify_tolerance)
|
|
2826
2835
|
mask_threshold: Threshold for mask binarization (default: self.mask_threshold)
|
|
2827
|
-
|
|
2836
|
+
min_object_area: Minimum area in pixels to keep a building (default: self.min_object_area)
|
|
2837
|
+
max_object_area: Maximum area in pixels to keep a building (default: self.max_object_area)
|
|
2828
2838
|
nms_iou_threshold: IoU threshold for non-maximum suppression (default: self.nms_iou_threshold)
|
|
2829
2839
|
|
|
2830
2840
|
Returns:
|
|
@@ -2836,7 +2846,7 @@ def masks_to_vector(
|
|
|
2836
2846
|
|
|
2837
2847
|
print(f"Converting mask to GeoJSON with parameters:")
|
|
2838
2848
|
print(f"- Mask threshold: {mask_threshold}")
|
|
2839
|
-
print(f"- Min building area: {
|
|
2849
|
+
print(f"- Min building area: {min_object_area}")
|
|
2840
2850
|
print(f"- Simplify tolerance: {simplify_tolerance}")
|
|
2841
2851
|
print(f"- NMS IoU threshold: {nms_iou_threshold}")
|
|
2842
2852
|
|
|
@@ -2876,7 +2886,11 @@ def masks_to_vector(
|
|
|
2876
2886
|
area = stats[i, cv2.CC_STAT_AREA]
|
|
2877
2887
|
|
|
2878
2888
|
# Skip if too small
|
|
2879
|
-
if area <
|
|
2889
|
+
if area < min_object_area:
|
|
2890
|
+
continue
|
|
2891
|
+
|
|
2892
|
+
# Skip if too large
|
|
2893
|
+
if max_object_area is not None and area > max_object_area:
|
|
2880
2894
|
continue
|
|
2881
2895
|
|
|
2882
2896
|
# Create a mask for this building
|