将 GeoJSON 导入 MongoDB

Importing GeoJSON into MongoDB

我只是通过弄清楚如何将它们导入 MongoDB 来尝试使用 GeoJSON 的一些东西。这是我要导入的 JSON 数据的片段:

{
    "type": "FeatureCollection",
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
        }
    },
    "source": "© GeoBasis-DE / BKG 2013 (Daten verändert)",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "RS": "051580004004",
                "DES": "Stadt",
                "GEN": "Erkrath",
                "EWZ_M": 20929,
                "EWZ_W": 22883,
                "SHAPE_AREA": 26441754.911268
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            6.88238674728364,
                            51.24166234476658
                        ],
                        [
                            6.881975279589705,
                            51.23757802188462
                        ],
                        [
                            6.891756626701045,
                            51.23929422878399
                        ],
                        [
                            6.903180857084263,
                            51.23707789012778
                        ],
                        [
                            6.908259412237354,
                            51.24206723420193
                        ],
                        [
                            6.918977412277895,
                            51.24041847413137
                        ],
                        [
                            6.926662904165135,
                            51.24253596694298
                        ],
                        [
                            6.937590326994132,
                            51.23093391057761
                        ],
                        [
                            6.94295724765998,
                            51.2299892278866
                        ],
                        [
                            6.939417113978845,
                            51.227341409094315
                        ],
                        [
                            6.951333593915336,
                            51.22740615125517
                        ],
                        [
                            6.950253526637431,
                            51.224656373607054
                        ],
                        [
                            6.955765647972802,
                            51.22167757046095
                        ],
                        [
                            6.964606469495985,
                            51.22457614378809
                        ],
                        [
                            6.975480633820623,
                            51.223046741435965
                        ],
                        [
                            6.973404761769492,
                            51.22089502422256
                        ],
                        [
                            6.980214287180364,
                            51.21998473062592
                        ],
                        [
                            6.982741542191386,
                            51.214167748907066
                        ],
                        [
                            6.994804384322499,
                            51.215655729126155
                        ],
                        [
                            6.994747626413055,
                            51.21224925095131
                        ],
                        [
                            6.985928005605313,
                            51.20743852466108
                        ],
                        [
                            6.98828820437737,
                            51.20347146797952
                        ],
                        [
                            6.944606700602787,
                            51.198908942197114
                        ],
                        [
                            6.943253716046289,
                            51.19637267292547
                        ],
                        [
                            6.937329237188316,
                            51.19846226521679
                        ],
                        [
                            6.932905519738434,
                            51.194111787062006
                        ],
                        [
                            6.907388585403191,
                            51.19594285093562
                        ],
                        [
                            6.903803051706552,
                            51.20313804926765
                        ],
                        [
                            6.910551758112292,
                            51.21099091708282
                        ],
                        [
                            6.878932812936605,
                            51.21491884904021
                        ],
                        [
                            6.872564112818471,
                            51.219486802570856
                        ],
                        [
                            6.873244797535404,
                            51.226155851357795
                        ],
                        [
                            6.878496898776498,
                            51.22869664243089
                        ],
                        [
                            6.872981880136851,
                            51.232966792978665
                        ],
                        [
                            6.871618163754948,
                            51.24209470504303
                        ],
                        [
                            6.88238674728364,
                            51.24166234476658
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "properties": {
                "RS": "051160000000",
                "DES": "Stadt",
                "GEN": "Mönchengladbach",
                "EWZ_M": 123662,
                "EWZ_W": 131172,
                "SHAPE_AREA": 170540962.920759
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                     .....
                     .....

我现在想将此数据导入我的 MongoDB 实例。当我尝试以下操作时,我 运行 遇到了一些错误:

mongoimport --db /Users/joe/mongodb-data -c points --file "gemeinden_simplify200.geojson" --jsonArray

connected to: 127.0.0.1
assertion: 13106 nextSafe(): { $err: "Invalid ns [/Users/joe/mongodb-data.points]", code: 16256 }

我觉得你需要试试-

 mongoimport --db test -c points --file "gemeinden_simplify200.geojson" --jsonArray

这里test是数据库名。