我有一个这种形式的GeoJson文件(示例如下所示):
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"prop0": "value0"
}
}, {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0]
]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
}, {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
},
"properties": {
"prop0": "value0",
"prop1": {
"this": "that"
}
}
}]
}
当我在一个名为sampledb
的表中将此文件导入mongo时
并在一个名为samplecol
的集合中使用此命令mongoimport --db sampledb --collection samplecol --drop --file /home/ec2-user/sample.json
我在mongo shell中执行:
db.samplecol.findOne()
此命令返回所有功能。我想知道如何将GeoJSON功能存储到集合中的单个文档中而不是一个具有嵌套功能的文档。
提前致谢。