---
title: "Are you using the right Mongo geospatial query?"
description: "MongoDB's `$geoWithin` with `$center` computes radius queries in planar longitude/latitude space, so at Los Angeles's latitude a nominal 25km circle becomes an egg that drops points to the east and west."
url: "https://swe.quest/articles/are-you-using-the-right-mongo-geospatial-query-fbd8f2184a17e5cf"
canonical: "https://artsy.github.io/blog/2023/02/10/mongo-geospatial-queries/"
source: "Artsy Engineering"
published: "2023-02-10"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["geospatial","databases","debugging"]
---

# Are you using the right Mongo geospatial query?

A post on [Artsy Engineering](https://swe.quest/sources/artsy.md), published 2023-02-10, 8 min read, Case study. Original: [https://artsy.github.io/blog/2023/02/10/mongo-geospatial-queries/](https://artsy.github.io/blog/2023/02/10/mongo-geospatial-queries/)

## Summary

MongoDB's \`$geoWithin\` with \`$center\` computes radius queries in planar longitude/latitude space, so at Los Angeles's latitude a nominal 25km circle becomes an egg that drops points to the east and west. A Santa Monica gallery missing from Artsy's LA show listings was traced to this, and switching to \`$centerSphere\` with the radius in radians (km / 6378.1) fixed it. The investigation used Placemark to plot query results against a grid of test points and compare them with a geodesic circle. A postscript covers why the distortion happens, using the equirectangular and Mercator projections and Tissot's indicatrix.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Maps & geospatial](https://swe.quest/tags/geospatial.md) (Domains)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)

## Prerequisites

- MongoDB queries
- latitude/longitude coordinates

## Keywords

MongoDB, $geoWithin, $centerSphere, Placemark, Mercator projection, Tissot's indicatrix

## Related posts

- [Geo Queries with PostGIS in Ionic Angular](https://swe.quest/articles/geo-queries-with-postgis-in-ionic-angular-9afa3d65d6fa3030.md): Supabase · 2023-03-01 · Medium · 20 min read · PostgreSQL, Maps & geospatial, Mobile, Frontend
  PostGIS on Supabase handles geo data for an Ionic Angular app with a Capacitor Google Map.
- [Visualizing Foursquare places with ClickHouse](https://swe.quest/articles/visualizing-foursquare-places-with-clickhouse-7a2e9fe18ad158f7.md): ClickHouse · 2025-05-08 · Medium · 5 min read · Maps & geospatial, Analytics & OLAP, SQL
  The Foursquare open places dataset (about 100 million records) loads straight from S3 Parquet into ClickHouse in 42 seconds and 11 GB.
- [Frontend Engineering at Palantir: Polar Scaled Tiles in Zodiac](https://swe.quest/articles/frontend-engineering-at-palantir-polar-scaled-tiles-in-zodiac-eafc54559cb5567a.md): Palantir · 2026-04-15 · Medium · 9 min read · Maps & geospatial, Frontend, Performance engineering, TypeScript, Algorithms
  Equal-angle lat/long map tiles collapse into tiny slivers near the poles on a 3D globe, so Zodiac, Palantir's Three.js globe library, was generating far too much geometry in polar regions.
- [Maps with PostgreSQL and PostGIS](https://swe.quest/articles/maps-with-postgresql-and-postgis-b8b01c8d5b51a400.md): Zalando Engineering · 2021-12-01 · Medium · 7 min read · Maps & geospatial, PostgreSQL, Kubernetes, Frontend
  PostGIS can generate Mapbox vector tiles directly, so a browser map needs only PostgreSQL/PostGIS, a thin tile server (pg\_tileserv) and a Leaflet frontend, with no heavy tiling middleware.
- [State of Geospatial in ClickHouse in March 2026](https://swe.quest/articles/state-of-geospatial-in-clickhouse-in-march-2026-8ba2f9b2ba169467.md): ClickHouse · 2026-03-04 · Medium · 29 min read · Maps & geospatial, Analytics & OLAP, SQL, Databases
  ClickHouse's geospatial support has grown from early distance functions to over 90 functions, grid indexes (geohash, H3, S2), and geometry types (Point, Ring, LineString, MultiLineString, Polygon, MultiPolygon) implemented as aliases over Tuple and Array.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
