Since Geojson is actual json I thought i could to use mongoimport to load data into my MongoDB database from a .geojson file.
but i'm getting the following error:
exception:BSON representation of supplied JSON is too large: code FailedToParse: FailedToParse: Expecting '{': offset:0
The file is 25MB and this is a fragment of it:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "id": "node/2661561690", "properties": { "timestamp": "2014-02-08T17:58:24Z", "version": "1", "changeset": "20451306", "user": "Schandlers", "uid": "51690", "natural": "tree", "id": "node/2661561690" }, "geometry": { "type": "Point", "coordinates": [ -66.9162255, 10.5056439 ] } }, // ... Omitted data { "type": "Feature", "id": "node/2664472516", "properties": { "timestamp": "2014-02-10T04:27:30Z", "version": "2", "changeset": "20477473", "user": "albertoq", "uid": "527105", "name": "Distribuidora Brithijos (Aceites)", "shop": "car_parts", "id": "node/2664472516" }, "geometry": { "type": "Point", "coordinates": [ -66.9388903, 10.4833647 ] } } ] }
Download jq (it's sed-like program but for JSON)
Then run:
jq --compact-output ".features" input.geojson > output.geojson
then
mongoimport --db dbname -c collectionname --file "output.geojson" --jsonArray
Right now you have an array of features. MongoDB will consider this to be one document. Try deleting the following from the beginning of your geojson:
{ "type": "FeatureCollection", "features": [
Also, delete the following from the end of your geojson:
] }
EDIT - Also, mongo expects one document per line. So make sure that your only \n is between documents! e.g.
... },\n { "type": "Feature", "id": "node/2664472516", ...
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