Osc*_*VGG 21 geospatial mongodb geojson
由于Geojson是实际的json,我想我可以使用mongoimport从.geojson文件将数据加载到我的MongoDB数据库中.
但我收到以下错误:
exception:BSON representation of supplied JSON is too large: code FailedToParse: FailedToParse: Expecting '{': offset:0
Run Code Online (Sandbox Code Playgroud)
该文件是25MB,这是它的一个片段:
{
"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
]
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
Par*_*roX 16
下载jq(它是类似sed的程序,但是对于JSON)
然后运行:
jq --compact-output ".features" input.geojson > output.geojson
然后
mongoimport --db dbname -c collectionname --file "output.geojson" --jsonArray
现在你有一系列的功能.MongoDB会将此视为一个文档.尝试从geojson的开头删除以下内容:
{
"type": "FeatureCollection",
"features": [
Run Code Online (Sandbox Code Playgroud)
另外,从geojson的末尾删除以下内容:
]
}
Run Code Online (Sandbox Code Playgroud)
编辑 - 此外,mongo预计每行一个文档.因此,请确保您的文件之间只有\n!例如
...
},\n
{
"type": "Feature",
"id": "node/2664472516",
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10288 次 |
| 最近记录: |