Define neighbour relationships according to contact distance treshold between polygon borders.
membrane_nb(poly, d.max = 0)
weighted neighbour matrix in a listw object from spdep package
Based on polygon intersection check done with st_intersects() function from sf package. When minimum distance is higher than 0, a round buffer of size max.dist/2 is applied to all polygons before calling st_intersects()