Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Ryerson University OpenStreetMap Hack Weekend Workshop on Using OSM Data in open source GIS
1. Workshop/Seminar (~1 hr)
Consuming OpenStreetMap Data in an
Open Source GIS
Michael Markieta <michael@spatialanalysis.ca>
Geographic Analysis – Ryerson University
Provided under CC-BY-SA 3.0. Please leave the attribution in tact but feel free to alter this work.
2. Now that we know all about OpenStreetMap
●
How should we consume OSM data?
– Data Formats
●
xml, shp, kml, etc...
– Methods
●
CLI tools, QGIS Plugins, ArcMap Extensions, etc...
– Performance
●
Mix of robustness, efficiency and ease of use
3. Where can I download OSM data?
●
Variety of mirrors that specialize in:
– Areas of the “planet” or the “planet” itself
– Update schedule (monthly, weekly, daily, etc...)
– Diffs (for tracking changes)
●
List of current “planet” mirrors:
http://wiki.openstreetmap.org/wiki/Planet.osm
– We can use this list to find extracts of smaller areas as
well (e.g.: City of Toronto, Melbourne, etc...)
4. Choosing an appropriate data format
●
Depends on:
– size
– intent
– skills
– wants/needs
●
Balancing act!
– No need for a full blown database
when all you need is a snapshot
of the Ryerson Campus buildings
●
Lets take a look at what kind of data is available here:
http://download.bbbike.org/osm/bbbike/
0
5
10
5. Selecting an extract format
Any GIS Software will open a “shapefile”
.osm files for database imports
7. Ubuntu 12.10 CLI
●
Working with the Toronto.osm.gz extract from bbbike.org
●
Add repositories, update, upgrade and install everything we need
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo add-apt-repository ppa:kakrueger/openstreetmap
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install qgis osm2pgsql
●
osm2pgsql will ask to automically create and configure a database, sounds good!
Give the postgres user a password:
sudo -u postgres psql postgres
password postgres
●
Just for reference
dbname=OSM username=postgres password=workshop
●
Add the PostGIS extension to our database
sudo su postgres
psql -U postgres OSM
CREATE EXTENSION postgis;
●
Download Toronto.osm.gz and unpack it (.gz means its compressed)
wget http://download.bbbike.org/osm/bbbike/Toronto/Toronto.osm.gz && gunzip Toronto.osm.gz
8. Ubuntu 12.10 CLI
●
Working with the toronto.osm.gz extract from bbbike.org
●
Populate the database with the Toronto.osm extract
sudo su postgres
osm2pgsql -s -U postgres -d OSM -W -E 'EPSG:4326' -G Toronto.osm
●
What does this do exactly?
osm2pgsql : the script that parses the toronto.osm file into the database
-s : run in slim mode (to reduce RAM usage incase we don't have enough)
-U postgres : database username
-d OSM : database name
-W : force password prompt
-E 'EPSG:4326' : coordinate system used to store the data (WGS84)
-G : generate multi-geometry (multi-point, multi-line, multi-polygon)
●
That's it! About 12 lines of code and we have put the latest data from
OpenStreetMap for Toronto into our database, ready to be queried.
9. Using QGIS to access the data
● Data stored as:
planet_osm_point
planet_osm_line
planet_osm_polygon
● Example query in SQL
select * from planet_osm_point where “amenity”='cafe';
● QGIS Query Builder
“amenity” = 'cafe'
10. Try it out on your own machine!
VMWare Virtual Machine running Ubuntu 12.10
QGIS File : “~/desktop/Toronto Demo.qgs”
Database : OSM <localhost postgres:workshop>
Data : Toronto
QGIS File : “~/desktop/Melbourne Demo.qgs”
Database : OSM2 <localhost postgres:workshop>
Data : Melbourne
Editor's Notes
Provided under CC-BY-SA 3.0 . Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0 . Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0 . Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0 . Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0. Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0. Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0. Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0. Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0. Please leave the attribution in tact but feel free to alter this work.
Provided under CC-BY-SA 3.0. Please leave the attribution in tact but feel free to alter this work.