Git Product home page Git Product logo

bccgis's Introduction

  1. Open terminal: Look for terminal in the menu

  2. Check the date

date
  1. Create a folder called 'code'
mkdir code
ls
  1. Go into the folder and check that it is empty
cd code
ls
  1. Check that make is installed
make
  1. Create a new makefile
gedit Makefile
  1. Put a sample task in the makefile
tellmethedate:
       date
  1. Download data from OpenStreetMap for Bangladesh
bangladesh.pbf:
    curl -o $@ 'http://download.geofabrik.de/asia/bangladesh-latest.osm.pbf'
  1. Install QGIS in order to open the file
sudo apt-get install qgis
  1. This file is too big, we have to make it smaller first before being able to open it in QGIS
sudo apt-get install openjdk-7-jre
wget http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-latest.zip
  1. Unzip osmosis
mkdir osmosis
cd osmosis
unzip ../osmosis-latest.zip
  1. Clone this repository
sudo apt-get install git
git clone https://github.com/ingenieroariel/bccgis.git
  1. Delete your files in the code folder that are not osmosis or bccgis.

  2. Move the osmosis folder in the bccgis folder.

  3. Every time you want to update your local copy, run the following:

git pull
  1. To add hospitals and restaurants in QGIS, Click on add layers, then select All Files and locate the pbf you want to open. If you do not know whether it has points, polygons or lines, click on select all, and then delete the layers that are empty.

  2. To create all the layers ( schools, rivers, restaurants, roads), make sure to do a git pull again and then type:

make clean
make

At this point the computer will start to download the country file for Bangladesh and extract all the important layers one by one. It will take about ten minutes and it is the perfect time to go and have tea.

  1. Export banks as an ESRI Shapefile using QGIS. Put it in a folder called export.

  2. Let's get a spatial database setup

sudo apt-get install postgresql-9.3-postgis-2.1
  1. Create bcc database
sudo su - postgres
createuser -s bcc
createdb -O bcc bcc
\q
exit
  1. Add postgis and hstore extensions to be able to load spatial data
psql bcc
CREATE EXTENSION postgis;
CREATE EXTENSION hstore;
\q
  1. Export sql using shp2pgsql
cd ~/code/bccgis/export
shp2pgsql banks.shp >> banks.sql
  1. Load the sql on the database.
psql bcc -f banks.sql
  1. Check how many banks are in the database:
psql bcc
SELECT count(*) from banks;
\q
  1. Get the first bank
SELECT osm_id, name, geom FROM banks LIMIT 1;
SELECT osm_id, name, ST_AsEWKT(geom) FROM banks LIMIT 1;
  1. Get all the banks that are one kilometer away from BCC
SELECT * FROM banks 
 WHERE ST_DWithin(geom, 'POINT(90.374281 23.7784036)', 0.01);
  1. Update your code, and run make all to insert all the different tables in the database.

  2. Install pgadmin3 to access your database with a handy UI.

sudo apt-get install pgadmin3
  1. Set a password for the bcc user.
psql bcc
ALTER ROLE bcc WITH PASSWORD 'bcc';
\q
  1. Open pgadmin3 from the menu and connect to the server at localhost. Open the bcc database and navigate to the list of tables in the public schema until you see the bank table. Right click on that table and click on View Data -> View Top 100 Rows.

  2. Install python-pip before you can install Django

sudo apt-get install python-pip
sudo pip install Django
  1. Run the web server on the bccdjango project. In order to create this application, we ran django-admin startproject bccdjango in the teacher computer and then pushed the results to github.
cd bccdjango
python manage.py runserver

Navigate to the web browser in the following url: http://localhost:8000/

  1. Now try to access the list of banks: We used python manage.py inspectdb to create a models.py file with information about banks and other type of layers and created a new app called osm using python manage.py startapp osm.
git pull

http://localhost:8000/banks

  1. Update the postgres python adapter:
sudo apt-get install libpq-dev python-dev
sudo pip install -U psycopg2 ipython
  1. Use the shell to iterate over bank names:
python manage.py shell
from osm.models import Bank

Bank.objects.all().count()

for bank in Bank.objects.all():
    print bank.name, bank.geom.x, bank.geom.y
  1. Install django-leaflet and django-geojson to be able to create a map.
sudo pip install django-leaflet django-geojson

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.