All changes
This commit is contained in:
parent
593f380581
commit
49f7ec2f5a
60 changed files with 1783 additions and 679 deletions
|
|
@ -306,7 +306,7 @@ def _build(
|
|||
.rename(
|
||||
{
|
||||
"date_of_transfer": "Date of last transaction",
|
||||
"construction_age_band": "Construction age",
|
||||
"construction_age_band": "Construction year",
|
||||
"is_construction_date_approximate": "Is construction date approximate",
|
||||
"pp_address": "Address per Property Register",
|
||||
"epc_address": "Address per EPC",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from collections import defaultdict
|
|||
|
||||
import numpy as np
|
||||
from scipy.spatial import Voronoi
|
||||
from scipy.spatial.qhull import QhullError
|
||||
from shapely import make_valid
|
||||
from shapely.geometry import MultiPolygon, Polygon
|
||||
from shapely.ops import unary_union
|
||||
|
|
@ -67,7 +68,7 @@ def compute_voronoi_regions(
|
|||
|
||||
try:
|
||||
vor = Voronoi(all_points)
|
||||
except Exception:
|
||||
except (ValueError, QhullError):
|
||||
# Fallback: split boundary equally among all postcodes present
|
||||
all_pcs = list(dict.fromkeys(unique_pcs))
|
||||
if len(all_pcs) == 1:
|
||||
|
|
|
|||
|
|
@ -8,10 +8,14 @@ Source: Ordnance Survey GeoSure (Open Data)
|
|||
"""
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import polars as pl
|
||||
from pathlib import Path
|
||||
import shapefile as shp
|
||||
from pyproj import Transformer
|
||||
from shapely import STRtree, points
|
||||
from shapely.geometry import shape as to_shapely
|
||||
|
||||
_GEOSURE_RISKS = [
|
||||
("CollapsibleDeposits", "collapsible_deposits_risk"),
|
||||
|
|
@ -25,11 +29,6 @@ _GEOSURE_RISKS = [
|
|||
|
||||
def transform(geosure_dir: Path, arcgis_path: Path) -> pl.DataFrame:
|
||||
"""Spatial-join GeoSure 5km hex grid risk data to postcode centroids."""
|
||||
import shapefile as shp
|
||||
from pyproj import Transformer
|
||||
from shapely import STRtree, points
|
||||
from shapely.geometry import shape as to_shapely
|
||||
|
||||
to_wgs84 = Transformer.from_crs("EPSG:27700", "EPSG:4326", always_xy=True)
|
||||
|
||||
print("Loading postcode centroids for GeoSure join...")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue