Workshop:�Using OpenStreetMap Data
Benjamin Herfort, Melanie Eckle,�Marcel Reinmuth
GIScience Research Group
Heidelberg University
disastermappers heidelberg
GeOnG Forum 2016, Chambéry, France
Agenda
2
GeOnG Forum 2016, Chambéry, France
Agenda
3
GeOnG Forum 2016, Chambéry, France
OSM data on your mobile device ::�download data via BBBike.org
4
GeOnG Forum 2016, Chambéry, France
OSM data on your mobile device ::�download data via HOT Export Tool
5
GeOnG Forum 2016, Chambéry, France
OSM data on your mobile device ::�Insert data to your device
OSMand:
Garmin:
6
GeOnG Forum 2016, Chambéry, France
Get OSM data
7
GeOnG Forum 2016, Chambéry, France
Agenda
8
GeOnG Forum 2016, Chambéry, France
Get OSM data :: Overpass-API and overpass-turbo
Overpass-API intro:
You need everything for large areas?
9
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: filter by tag
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity=school”
*/
[out:json][timeout:25];
// gather results
(
// query part for: “amenity=school”
node["amenity"="school"]({{bbox}});
way["amenity"="school"]({{bbox}});
relation["amenity"="school"]({{bbox}});
);
// print results
out body;
>;
out skel qt;
10
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: filter by tag
/*
The original search was:
“highway=trunk and ref=RN1”
*/
[out:json][timeout:25];
// gather results
(
// query part for: “highway=trunk and ref=RN1”
node["highway"="trunk"]["ref"="RN1"]({{bbox}});
way["highway"="trunk"]["ref"="RN1"]({{bbox}});
relation["highway"="trunk"]["ref"="RN1"]({{bbox}});
);
// print results
out body;
>;
out skel qt;
11
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: filter by area
/*
The original search was:
“highway=* in Chambery”
*/
[out:json][timeout:25];
// fetch area “Chambery” to search in
{{geocodeArea:Chambery}}->.searchArea;
// gather results
(
// query part for: “highway=*”
node["highway"](area.searchArea);
way["highway"](area.searchArea);
relation["highway"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
12
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: filter by username
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“user:Hagellach37”
*/
[out:json][timeout:25];
// gather results
(
// query part for: “user:Hagellach37”
node(user:"Hagellach37")({{bbox}});
way(user:"Hagellach37")({{bbox}});
relation(user:"Hagellach37")({{bbox}});
);
// print results
out body;
>;
out skel qt;
13
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo ::
get only latest/new OSM data
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“newer:"2016-10-01T00:00:00Z"”
*/
[out:json][timeout:25];
// gather results
(
// query part for: “newer:"2016-10-01T00:00:00Z"”
node(newer:"2016-10-01T00:00:00Z")({{bbox}});
way(newer:"2016-10-01T00:00:00Z")({{bbox}});
relation(newer:"2016-10-01T00:00:00Z")({{bbox}});
);
// print results
out body;
>;
out skel qt;
14
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo ::
get historic OSM data
/*
The original search was:
“idp:camp_site=spontaneous_camp ”
*/
[out:json][timeout:25][date:"2015-05-05T00:00:00Z"];
// gather results
(
// query part for: “"idp:camp_site"=spontaneous_camp”
node["idp:camp_site"="spontaneous_camp"]({{bbox}});
way["idp:camp_site"="spontaneous_camp"]({{bbox}});
relation["idp:camp_site"="spontaneous_camp"]({{bbox}});
);
// print results
out body;
>;
out skel qt;
15
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: output meta data
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“idp:camp_site=spontaneous_camp ”
*/
[out:json][timeout:25][date:"2015-05-05T00:00:00Z"];
// gather results
(
// query part for: “"idp:camp_site"=spontaneous_camp”
node["idp:camp_site"="spontaneous_camp"]({{bbox}});
way["idp:camp_site"="spontaneous_camp"]({{bbox}});
relation["idp:camp_site"="spontaneous_camp"]({{bbox}});
);
// print results
out meta;
>;
out skel qt;
16
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: export data and save queries
17
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: dynamic web map in uMap
18
GeOnG Forum 2016, Chambéry, France
Overpass-API and overpass-turbo :: dynamic web map in uMap
19
GeOnG Forum 2016, Chambéry, France
Agenda
20
GeOnG Forum 2016, Chambéry, France
OpenStreetMap-API: Get raw data
21
GeOnG Forum 2016, Chambéry, France
Agenda
22
GeOnG Forum 2016, Chambéry, France
OSM data in your database
23
GeOnG Forum 2016, Chambéry, France
OSM data in your database :: Prepare PostGIS database
Import data:
osmosis --read-pbf file="sud_kivu.osm.pbf" --write-pgsql host="123.208.218.97" database="missing_maps_kivu" user=“crazy_user" password=“crazy_password“
24
GeOnG Forum 2016, Chambéry, France
OSM data in your database :: Run your queries
SELECT count(*) FROM ways WHERE (tags @> '"amenity"=>"school"')
SELECT * FROM ways WHERE tags ? 'building‘
SELECT * FROM nodes WHERE (tags @> '"amenity"=>"school"') AND (tags ? 'name');
+ spatial queries and analysis:
25
GeOnG Forum 2016, Chambéry, France
OSM data in your database :: Load data in QGIS
26
GeOnG Forum 2016, Chambéry, France
Thank you. ☺
Eckle@uni-heidelberg.de
marcel.reinmuth@stud.uni-heidelberg.de
Herfort@uni-heidelberg.de
disastermappers@posteo.de
27
GeOnG Forum 2016, Chambéry, France