The MongoDB extension for geospatial databases
MongoDB supports the GeoJSON object types Point
, LineString
, Polygon
, MiltiPoint
, MultiLineString
, MultiPolygon
, and GeometryCollection
. These are used in two-dimensional geometry and geographic surface-of-the-earth data.
Mongo provides a nice tutorial on geospatial databases with an application on restaurant locations in New York City here: https://docs.mongodb.com/manual/tutorial/geospatial-tutorial/.
A GeoJSON object has the form:
<field>: { type: <GeoJSON-type>, coordinates: [longitude, latitude]}
Here, <GeoJSON-type>
is one of the seven types listed previously, and longitude
and latitude
are decimal numbers, with range -180 < longitude
< 180 and -90 < latitude
< 90. For example, the following is the GeoJSON object for Westminster Abbey in London:
"location": {"type": "Point", "coordinates": [-0.1275, 51.4994]}
Notice that GeoJSON lists longitude before latitude, as with (x, y) coordinates. This is the reverse of...