Skip to content

使用pymongodb Geospatial Indexes 篩選資料並標示在地圖上

Notifications You must be signed in to change notification settings

JED-4a6g0109/pymongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geospatial Indexes (mongodb.ipynb內有詳細解說與註解)


如果不了解請觀看此影片https://www.youtube.com/watch?v=iGnSNfzaLf4

Windown10 前置作業(已安裝Anaconda Navigator、jupyter notebook)

1.Google map api

請按照 google docmentation 步驟 https://developers.google.com/places/web-service/get-api-key

如果未安裝mongodb環境

https://www.mongodb.com/download-center/community
選擇Windows X64 下載

安裝完後開啟C:\Program Files\MongoDB\Server\4.2\bin\mongo.exe
開啟mongo確定是否可使用

2.已經有安裝mongodb環境


pymongo安裝pip install pymongo

gmplot安裝pip install gmplot

3.安裝完pymongo後參考菜鳥教程 pymongo執行連線程式

import pymongo
myclient = pymongo.MongoClient("mongodb:https://localhost:27017/")
mydb = myclient["runoobdb"]
mycol = mydb["sites"]
x = mycol.find_one() 
print(x)

如果執行沒出現錯誤代表mongodb與pymongodb設定完成,如果有錯誤請自行google

4.開啟mongodb.ipynb一步步做(內有詳細註解與解說)

程式缺圖補解說

pymongo GEO2D near


near一律由最近到最遠

maxDistance 這邊距離 0.001 為100公尺,經過google map自己量測距離確定無誤

near

pymongo GEO2D BOX

near

pymongo GEO2D circle

near

參考文獻

菜鳥教程:https://www.runoob.com/python3/python-mongodb-insert-document.html


https://www.runoob.com/python3/python-mongodb-query-document.html


PyMongoDB documentation:https://pymongo.readthedocs.io/en/stable/examples/geo.html#creating-a-geospatial-index


Geospatial Indexes - Data Wranging with MongoDB:https://www.youtube.com/watch?v=iGnSNfzaLf4


gmplot:https://github.com/gmplot/gmplot

Releases

No releases published

Packages

No packages published