| | |
| | | vector = masks_to_vector(str(output_dir / "change_mask.tif"), str(vector_path), simplify_tolerance=1.0, mask_threshold=0.5, min_object_area=min_area) |
| | | features = _feature_summary(cleaned, probability, transform, actual_mode == "geotiff") |
| | | _enrich_vector(vector_path, features, preserve_crs=actual_mode == "geotiff") |
| | | from rectangularize_vectors import rectangularize_vector |
| | | |
| | | rectangle_path = output_dir / "changes_rectangles.geojson" |
| | | rectangle_wgs84_path = output_dir / "changes_rectangles_wgs84.geojson" if actual_mode == "geotiff" else None |
| | | rectangle_count = rectangularize_vector(vector_path, rectangle_path, rectangle_wgs84_path) |
| | | (output_dir / "change_features.json").write_text(json.dumps({"features": features}, ensure_ascii=False, indent=2), encoding="utf-8") |
| | | limitations = [ |
| | | "GeoTIFF 输入保留 CRS 和地图坐标;若两期网格不同,会在处理副本中将第二期双线性重投影到第一期网格,原始 TIFF 不会被改写。" if actual_mode == "geotiff" else "输入 JPG/PNG 或无 CRS TIFF 没有有效 CRS,GeoTIFF/GeoJSON 坐标是像素换算坐标,不是米或经纬度。", |
| | |
| | | "changed_pixels": int((cleaned > 0).sum()), |
| | | "changed_pixel_ratio": round(float((cleaned > 0).mean()), 6), |
| | | "vector_feature_count": len(vector), |
| | | "rectangle_feature_count": rectangle_count, |
| | | "georeferenced": actual_mode == "geotiff", |
| | | "coordinate_basis": "source_crs_map_coordinates" if actual_mode == "geotiff" else "pixel_coordinates_north_up_transform_y_from_image_bottom", |
| | | "crs": output_crs, |
| | |
| | | "mask_raster": "change_mask.tif", |
| | | "overlay": "change_overlay.jpg", |
| | | "vector": "changes.geojson", |
| | | "rectangle_vector": "changes_rectangles.geojson", |
| | | "rectangle_vector_wgs84": "changes_rectangles_wgs84.geojson" if actual_mode == "geotiff" else None, |
| | | "features": "change_features.json", |
| | | }, |
| | | "limitations": limitations, |