Spatial Join in MongoDB: Joining Collections on Geometry within 1000 Meters


I hope this message finds you well. I have a question regarding performing a spatial join in MongoDB and joining two collections based on their geometry within a certain distance.

I have two collections: manchaster_polygons and manchaster_lines, both containing spatial data in the form of GeoJSON geometries. The manchaster_polygons collection consists of polygons representing buildings, while the manchaster_lines collection contains line data representing service roads.

I would like to perform a join operation between these two collections based on the spatial relationship between the polygons and the lines. Specifically, I want to find the buildings within 1000 meters from the service roads.

In SQL, I could achieve this using a spatial query with the ST_DWithin function. However, I am unsure how to accomplish this in MongoDB’s query language.
Thanks in Advance