I have two dataframes, one with line features and another one with point features. Each point has the id of an object in the linefeatures-dataset as a value in a column.
Now I need to calculate the minimal distance between each point and its relevant line. For this I have to get the line-id from the point feature and then search it in the line-dataframe, and only then calculate the distance between the two geometries by using geopandas-methodGeoPandas method 'distance' like:
def min_distance(point, lines):
return lines.distance(point).min()
df_points['min_dist_to_lines'] = df_points.geometry.apply(min_distance, args=(df_lines,))
However, before that, I need to check for the line ids. Is there a way to do this efficiently, without iterating both dfs? I have a modest size of data and can imagine, that the iterating will slow down the processing.