I'm trying to calculate the minimum distance between a set a polygons, and a subset thereof. I've used a quick-and-dirty GeoPandas
df['subset_distance'] = df.geometry.apply(lambda g: df_subset.distance(g).min())
which works, but it's pretty slow, even on my test dataset of around 700 polygons. I need to find the minimum distances for around 2 million polygons and a subset of 4k polygons, so I suspect I'm going to need a different strategy. Could anyone suggest a better approach? I'm comfortable with PostGIS, and any combination of Python spatial libraries.