.geojson --> MongoDB

mongoimport only accepts valid json file which is one line per record while .geojson structs in a way that one record isn’t fit in one line.

So jq comes into play to solve .geojson to a valid json mongoimport understands.

jq --compact-output ".features" bangkok_thailand_osm_polygon.geojson > bkk-poly.geojson

jq for OSX is a easy tool available via brew


It’s easy peachy.

mongoimport --db mapfy -c bkk --file "bkk-ply.geojson" --jsonArray

All data will be available in Geospatial format automatically as it should be.

For info regarding Geospatial MongoDB