I have polygon layer in QGIS, and for each polygon I would like to calculate the minimum distance to the nearest polygon in another layer. My desired result is an attribute for all features that has the minimum distance from that feature to another layer. (context: it's a sort of (ecological) connectivity analysis)
I got a lead to using PostGIS, so I installed that successfully and loaded the dataset into a PostGIS database. I think the function ST_Distance might be the right tool, but I don't know enough SQL to construct the right query.
Sample of my dataset: I want to know the shortest distance between a red or yellow polygon tot a purple polygon. distance measured between outlines, not centroids or something.