Skip to main content
100%

mongodb geospatial tutorial

✓ Published0🌍 Public
Aaaizemberg
Last edited Apr 9, 2019
Created on Apr 9, 2019

This example demonstrates MongoDB’s geospatial query capabilities for locating restaurants within New York City neighborhoods. It shows how to find a neighborhood containing a given point, count restaurants inside that neighborhood, and filter restaurants by proximity using spherical distance calculations. The code uses MongoDB’s `2dsphere` indexes, `$geoIntersects`, `$geoWithin`, `$centerSphere`, and `$nearSphere` operators against imported GeoJSON datasets (`neighborhoods.json` and `restaurants.json`). It also illustrates the earth’s radius in kilometers and miles for distance thresholds.

AI-generated description

Similar vizzes