overpass api 找公司附近的便利商店 並 Import 到 MongoDb 內## overpass apihttps://overpass.kumi.systems/api/interpreter wiki
1 2 3 4 5 6 //[out:json][timeout:25]; ( node["shop"="convenience"](25.07,121.56,25.09,121.58); <; ); out body;
出來的會是xml file 試著轉成geoJSON 在overpass的網頁上可以直接轉https://overpass.nchc.org.tw/overpass-turbo/
轉完後還無法用mongoimport 只需要features內的值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 "type": "FeatureCollection", "generator": "overpass-turbo", "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.", "timestamp": "", "features": [ { "type": "Feature", "id": "node/1837853348", "properties": { "@id": "node/1837853348", "history": "retrieved using undelete JOSM plugin", "name": "全家", "shop": "convenience" ... ... ...
可利用 jq
工具 轉成所需的json fileHow to import Geojson file to MongoDB
1 2 3 jq --compact-output ".features" input.geojson > output.geojson mongoimport --db dbname -c collectionname --file "output.geojson" --jsonArray
完成啦~
MongoDb Query 查詢 一次顯示的資料筆數變多 不用再it it it 1 DBQuery.shellBatchSize = 300
here
mongoimport https://docs.mongodb.com/manual/reference/program/mongoimport/
Overpass暫存一些語法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 // query part for: “shop” node["shop"="convenience"](25.07,121.56,25.09,121.58); way["shop"]({{bbox}}); relation["shop"]({{bbox}}); node["shop"="department store"]({{bbox}}); node["shop" = "mall"]({{bbox}}); node["construction:shop" = "department store"]({{bbox}}); node["shop" = "department_store"]({{bbox}}); node["shop"]({{bbox}}) && node["shop" = "department_store"]({{bbox}}); {{geocodeArea:Taiwan}}->.searchArea; // gather results ( // query part for: “tourism=museum” node["tourism"="museum"](area.searchArea); way["tourism"="museum"](area.searchArea); relation["tourism"="museum"](area.searchArea); );