Bahan ajar pengenalan geojson https://bukped.github.io/geojson/
- Make sure you read this section https://github.com/awangga/nopanel/blob/master/git.md
- Fork this repo
- Clone into your desktop using git clone ssh
- Set upstream first
- Working in your task
- Pull request after fetch upstream
- Select a place in Bandung City (Public Place, Government Place, Edu Place)
- Create 10 poligon type in that place store in bandung folder, save it ad geojson format and rename it to placename.json
- Insert it into mongo db provided by lecturer using mongo compass https://www.mongodb.com/products/compass
- Pull Request Subject : 8-KELAS-NPM-NAMA
- Go home
- http://download.geofabrik.de/asia/indonesia.html
- https://openstreetmap.or.id/en/data-openstreetmap-indonesia/
- https://www.arrayiterator.com/kodepos-geocoding-json-seluruh-indonesia-sesuai-bps
- https://ibnux.github.io/data-indonesia/
- https://github.com/superpikar/indonesia-geojson
- https://github.com/pararawendy/border-desa-indonesia-geojson use string replace
For pararawendy/border-desa-indonesia-geojson data, to change into GeoJSON standar format :
replace : "border":[[[
with : "border":[[
AND
replace : ]]]}
with : ]]}
THEN
replace : "border":[
with : "border":{"type":"Polygon","coordinates": [[
AND
replace : ]}
with : ]]}}
Query with current coordinat
{
border: {
$geoIntersects: {
$geometry: {
type: "Point" ,
coordinates: [ 107.575902278736,-6.8732786951873255 ]
}
}
}
}- You might Using google colab to download data and mongo db tools it into your google drive.
import os
from google.colab import drive
drive.mount('/content/drive')
folder = '/content/drive/My Drive/Download/dl'
savedir=folder
os.chdir(savedir) #change dir
!pwd
!ls
!pip install pygeos
!pip install pyrosm
!wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu1804-x86_64-100.6.1.deb
!sudo apt install ./mongodb-database-tools-ubuntu1804-x86_64-100.6.1.deb
!curl http://ip-api.com/json
!wget https://github.com/pararawendy/border-desa-indonesia-geojson/raw/master/indonesia_villages_border.geojson.zip
!unzip indonesia_villages_border.geojson.zipto manipulate the data you might use this script
# Read in the file
with open('indonesia_villages_border.geojson', 'r') as file :
filedata = file.read()
# Replace the target string
filedata = filedata.replace('"border":[[[', '"border":[[')
filedata = filedata.replace(']]]}', ']]}')
filedata = filedata.replace('"border":[', '"border":{"type":"Polygon","coordinates": [[')
filedata = filedata.replace(']}', ']]}}')
# Write the file out again
with open('village.geojson', 'w') as file:
file.write(filedata)
- Cree free tier database from mongodb.com connect it with your mongo compass. Add query IP Address from step 1. and create db, collection and index with colab.Choose one city/residence, make sure city different from other insert the city data into your mongodb using colab or compass. Import to notvalid collection first.
!mongoimport --uri="mongodb+srv://awangga:rollyganteng@serverlessinstance0.wginu.mongodb.net/location" --collection=notvalid village.geojson --jsonArray- Make sure you have set index for border field in 2d geosphere.
import pymongo
mongostring="mongodb+srv://user:pass@dbname.host.mongodb.net/"
myclient = pymongo.MongoClient(mongostring)
mydb = myclient["location"]
mycol = mydb["villages"]
mycol.drop()
mydb = myclient["location"]
mycol = mydb["villages"]
mycol.create_index( [("border" , pymongo.GEOSPHERE )] )
!mongoimport --uri="mongodb+srv://user:pass@dbname.host.mongodb.net/location" --collection=villages village.geojson --jsonArray- Solving Edge or geometri invalid format. You might using pygeos, geojson.io or other visualization tools.
- Export it and convert to geojson format like in https://leafletjs.com/examples/geojson/ put in in data folder with city name.json (example: ulbi.json)
{
"type": "Feature",
"properties": {
"name": "ALUE BULOH"
},
"province": "ACEH",
"district": "ACEH TIMUR",
"sub_district": "BIREM BAYEUN",
"village": "ALUE BULOH",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
97.9666,
4.4451
],
[
97.9665,
4.4451
],
[
97.9665,
4.4451
],
[
97.9666,
4.4451
]
]
]
}
}
- Pull Request Subject : 9-KELAS-NPM-NAMA ,
- Description : please include your screenshoot of indexes and mongo compass access
- After Approved you are done
