Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoengine geospatial search

Has anyone used geospatial searching with mongengine? I can't seem to get it to work! What is the format of the data that has to go in the GeoPointField?

How should i format it? I can't find anything about the formating in the documentation!

like image 250
verrochio Avatar asked Jul 20 '12 20:07

verrochio


People also ask

What is geospatial search?

Geospatial queries are specialized types of SQL queries supported in Athena. They differ from non-spatial SQL queries in the following ways: Using the following specialized geometry data types: point , line , multiline , polygon , and multipolygon .

Does MongoDB support geospatial?

In MongoDB, you can store geospatial data as GeoJSON objects or as legacy coordinate pairs.

Is MongoDB good for spatial data?

MongoDB is a NoSQL database that is rapidly gaining popularity. All data is stored in JSON which works awesome on Node. js. MongoDB is capable of geospatial queries when set up properly.

Is MongoDB a spatial database?

MongoDB, which is a NoSQL Database, allows storing of Geospatial Data in the form of multiple GeoJSON types. Geospatial Feature of MongoDB makes it easy to store Geographical data into a database. So, basically, you can store the geospatial type data in the MongoDB in the form of GeoJSON objects.


1 Answers

Can you post what you are trying to do??

Point data must be stored in a field with key

"loc":{"lon":51.10682735591432, "lat":-114.11773681640625} or

loc: [22.23432, 21.23212]

With mongoengine there is support for a geopoint field

Class Location:
  point = GeoPointField()

new_location = Location(point=[21.1232,23.23432])
new_location.save()

something like above should work.

class GeoPointField(db_field=None, name=None, required=False, default=None, unique=False, unique_with=None, primary_key=False, validation=None, choices=None, verbose_name=None, help_text=None):

A list storing a latitude and longitude.

New in version 0.4.

http://mongoengine-odm.readthedocs.org/en/latest/apireference.html#mongoengine.GeoPointField

like image 126
dm03514 Avatar answered Sep 29 '22 00:09

dm03514