Skip to content

Troubleshooting

X must be a geopandas.GeoDataFrame

Convert a pandas DataFrame and select its geometry column:

import geopandas as gpd

edges = gpd.GeoDataFrame(table, geometry="geometry", crs="EPSG:27700")

Missing cost column

Either configure the correct column:

SpatialDeformer(cost="travel_time_s").fit(edges)

or pass the costs as y:

SpatialDeformer().fit(edges, y=travel_times)

Disconnected components

SpatialDeform does not invent target distances between disconnected networks. Split components and fit them separately, or add meaningful connector edges. Do not add a tiny arbitrary edge purely to silence the validation; it will dominate shortest paths and distort the result.

Geographic CRS rejected

The optimizer needs planar coordinates. Keep auto_project=True, or project explicitly:

edges = edges.to_crs(edges.estimate_utm_crs())
model = SpatialDeformer(auto_project=False).fit(edges)

Lines that should meet become separated

When endpoint IDs are inferred, inspect the rounded coordinates:

model = SpatialDeformer(source=None, target=None, node_precision=7)

If reducing precision joins unrelated nodes, repair topology instead of reducing it further.

Distortion is too weak

  • decrease geo_weight;
  • use a fixed scale derived from a reference scenario;
  • confirm costs actually vary across the network;
  • inspect graph_distances_ rather than only edge costs.

Distortion is too strong

  • increase geo_weight;
  • use Gaussian spatial weights;
  • increase spatial_bandwidth gradually;
  • inspect extreme costs and disconnected-looking bottlenecks.

Uniform slowdown does not expand the map

This is expected when every scenario independently uses scale="auto". Fit a reference state once and reuse its scale_ for every comparison state.

Installation starts compiling geospatial dependencies

Use a supported Python version and update pip. On unusual architectures, use a distribution that provides GeoPandas and SciPy binaries or install through conda-forge before installing SpatialDeform.

Reporting a problem

Include:

  • SpatialDeform and Python versions;
  • GeoPandas, Shapely, NumPy, SciPy, and scikit-learn versions;
  • CRS and geometry types;
  • whether topology uses columns or endpoint inference;
  • the complete exception traceback;
  • a minimal, non-sensitive reproducer if possible.

Open an issue in the GitHub repository.