(df_source, df_query, k_nearest=3)
| 122 | return config |
| 123 | |
| 124 | def interpolate_missing_properties(df_source, df_query, k_nearest=3): |
| 125 | import pandas as pd |
| 126 | from scipy.spatial import KDTree |
| 127 | xyz = list('xyz') |
| 128 | |
| 129 | print('generating a simplified point cloud (this may take a while...)') |
| 130 | |
| 131 | tree = KDTree(df_source[xyz].values) |
| 132 | _, ii = tree.query(df_query[xyz], k=k_nearest) |
| 133 | n = df_query.shape[0] |
| 134 | |
| 135 | df_result = pd.DataFrame(0.0, index=range(n), columns=df_source.columns) |
| 136 | df_result[xyz] = df_query[xyz] |
| 137 | other_cols = [c for c in df_source.columns if c not in xyz] |
| 138 | |
| 139 | for i in range(n): |
| 140 | m = df_source.loc[ii[i].tolist(), other_cols].mean(axis=0) |
| 141 | df_result.loc[i, other_cols] = m |
| 142 | |
| 143 | return df_result |
| 144 | |
| 145 | def exclude_points(df_source, df_exclude, radius): |
| 146 | from scipy.spatial import KDTree |
no outgoing calls
no test coverage detected