geopfa.extrapolation.backfill_gdf_at_height¶
- backfill_gdf_at_height(gdf, *, value_col, z_value, z_tol, X_grid, Y_grid, backfilled_array)[source]¶
Backfill missing values in a GeoDataFrame at a specific Z slice using a precomputed 2D grid of fill-in predictions.
Only rows whose
zcoordinate is withinz_value ± z_toland whosevalue_colis NaN will be filled. The fill values are obtained via nearest-neighbor lookup in the X-Y plane from the provided grid.- Parameters:
gdf (geopandas.GeoDataFrame) – Input GeoDataFrame containing numeric columns
'x','y','z', and the targetvalue_col.value_col (str) – Column name of the variable to fill.
z_value (float) – The Z slice to target.
z_tol (float) – Allowed absolute difference between a point’s
zandz_value.X_grid (numpy.ndarray) – 2-D array of X coordinates defining the grid.
Y_grid (numpy.ndarray) – 2-D array of Y coordinates defining the grid.
backfilled_array (numpy.ndarray) – 2-D array of predicted values corresponding to
X_grid/Y_grid.
- Returns:
geopandas.GeoDataFrame – A copy of the input GeoDataFrame where NaNs in
value_colat the specified Z slice have been replaced with nearest-neighbor grid values.
Notes
Points outside the Z tolerance range are not modified.
Only NaN entries are filled; existing values are left unchanged.
Nearest-neighbor search is performed using
scipy.spatial.cKDTree.Grid shapes must match:
X_grid.shape == Y_grid.shape == backfilled_array.shape.