I have the following problem with MongoDB. I got some geo data from my home country and i have to store them into mongodb to set up a simple Web Feature Service. This service will mostly do bounding box queries using the $within
operator. The data is in GeoJSON format. Therefore i imported at first the Villages and Cities which are represented as points ([1,2]
) in this format. No problem. Next step rivers and streets which are LineStrings and according to GeoJSON represented this way [[1,2],[3,4]]
. But when importing the districts (which are in fact polygon and according to the GeoJSON specification 3 dim arrrays) i got the error geo values have to be numbers
when creating the index.
db.collection.ensureIndex({"geometry.coordinates" : "2d"});
All data are valid GeoJSON, and are in plain 2d coordinates in EPSG:4326 projection.
Does anybody have an idea?
Overview. MongoDB supports the GeoJSON object types listed on this page. a field named coordinates that specifies the object's coordinates.
In MongoDB, you can store geospatial data as GeoJSON objects or as legacy coordinate pairs.
Nothing is in the wrong order. Leaflet uses lat-lng (or northing-easting ) whereas GeoJSON uses lng-lat (or easting-northing ).
A multiPolygon is an array of Polygon coordinate arrays. This adheres to the RFC 7946 internet standard when serialized into JSON. When deserialized, this class becomes an immutable object which should be initiated using its static factory methods.
With MongoDB 2.4 use the "2dsphere" index for GeoJSON Points, LineStrings and Polygons.
For example, you can create this index:
db.mycoll.ensureIndex( { loc : "2dsphere" } )
And store this LineString:
{ loc : { type : "LineString" , coordinates : [ [ 1 , 2 ] , [ 3 , 4 ] ] } }
See http://docs.mongodb.org/manual/applications/2dsphere/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With