|
1 | 1 | # osm2rdf |
2 | 2 |
|
3 | | -`osm2rdf` is a tool for converting the complete [OpenStreetMap](https://www.openstreetmap.org) (OSM) data to [RDF Turtle](https://www.w3.org/TR/turtle) (TTL). |
| 3 | +`osm2rdf` is a tool for converting [OpenStreetMap](https://www.openstreetmap.org) (OSM) data to [RDF Turtle](https://www.w3.org/TR/turtle) (TTL). |
4 | 4 |
|
5 | | -We consider the following prefixes being used in our code and documentation: |
| 5 | +It also pre-computes the spatial relations `sfIntersects`, `sfContains`, `sfCovers`, `sfTouches`, `sfCrosses`, `sfOverlaps`, and `sfEquals` between all OSM objects. |
6 | 6 |
|
7 | | -``` |
8 | | -PREFIX ogc: <http://www.opengis.net/rdf#> |
9 | | -PREFIX geo: <http://www.opengis.net/ont/geosparql#> |
10 | | -PREFIX osm2rdf: <https://osm2rdf.cs.uni-freiburg.de/rdf#> |
11 | | -``` |
12 | | - |
13 | | -The produced triples include: |
14 | | - |
15 | | -1. One triple `<o> <key> <value> .` for each key-value pair (called "tag" in OSM) of each object. |
16 | | -2. Two triples `<o> geo:hasGeometry <geom_o> . <geom_o> geo:asWKT <wkt> .` for the shape of each object (using [WKT](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) to represent the shape). |
17 | | -3. One triple `<o1> ogc:sfContains <o2> .` for each pair of objects, where `<o1>` geometrically contains `<o2>`. |
18 | | -4. One triple `<o1> ogc:sfIntersects <o2> .` for each pair of objects, where `<o1>` geometrically intersects `<o2>`. |
19 | | -5. Triples for various other kinds of information (see `osm2rdf --help` for the many options of the tool). |
20 | | - |
21 | | -For the complete OSM data, the tool takes around 15 hours on standard hardware and produces around 40 billion triples with a size of around 200 GB for the compressed TTL file. |
22 | | - |
23 | | -## Accompanying services and materials |
| 7 | +## Services and materials |
24 | 8 |
|
25 | | -Weekly updated downloads for the complete data as well as for each individual country are provided on https://osm2rdf.cs.uni-freiburg.de . |
| 9 | +Weekly updated downloads for the complete OSM as well as for individual countries are provided [here](https://osm2rdf.cs.uni-freiburg.de). |
26 | 10 |
|
27 | | -A SPARQL endpoint (based on [the QLever SPARQL engine](https://github.com/ad-freiburg/qlever)) for the complete OSM data is available under https://qlever.cs.uni-freiburg.de/osm-planet . The UI provides many example queries (click on the "Examples" button). |
| 11 | +A SPARQL endpoint (based on [the QLever SPARQL engine](https://github.com/ad-freiburg/qlever)) for the complete OSM data is available under https://qlever.dev/osm-planet. |
| 12 | +Example: [all buildings under a powerline](https://qlever.dev/osm-planet/Wd07W1). |
| 13 | +The UI provides more example queries (click "Examples"). |
28 | 14 |
|
29 | 15 | The basic method behind `osm2rdf` is described in [this SIGSPATIAL'21 paper](https://ad-publications.cs.uni-freiburg.de/SIGSPATIAL_osm2rdf_BBKL_2021.pdf). |
30 | 16 |
|
31 | | -The algorithm behind computing the predicates `geo:sfContains` and `geo:sfIntersects` will be published soon. For the complete OSM data, there are around 2 billion non-trivial geometric objects (this count excludes points that are merely base points of more complex shapes). It is very challenging to compute geometric relations between such a large number of objects in finite time. |
| 17 | +The methods behind computing the spatial relations are described in [this SIGSPATIAL'25 paper](https://ad-publications.cs.uni-freiburg.de/SIGSPATIAL_spatialjoin_BBK_2025.pdf). |
32 | 18 |
|
33 | | -## Getting started |
| 19 | +## Requirements |
34 | 20 |
|
35 | | -Some features require [boost](https://www.boost.org/) version **1.78 or newer**. |
36 | | -To enable these features boost has to be updated manually on most systems as distributions do ship older versions. |
| 21 | + * cmake |
| 22 | + * Compiler for C++17 |
| 23 | + * libexpat1 |
| 24 | + * zlib |
| 25 | + * libbz2 |
| 26 | + * libomp (optional, for multithreading) |
37 | 27 |
|
38 | | -### Docker |
| 28 | +## Quickstart |
| 29 | + |
| 30 | +Fetch this repo: |
39 | 31 |
|
40 | | -The provided `Makefile` contains targets which build a Docker image, prepare input and output directories and downloads data. |
41 | | -To run `osm2rdf` on germany it is enough to call: |
42 | 32 | ``` |
43 | | -make docker-de |
| 33 | +$ git clone https://github.com/ad-freiburg/osm2rdf.git |
44 | 34 | ``` |
45 | | -This creates the directories `input`, `output`, and `scratch`, downloads the data and runs `osm2rdf` with default parameters. |
46 | | - |
47 | | -Alternatively use the provided `Dockerfile` to compile and run `osm2rdf`: |
| 35 | +Build `osm2rdf`: |
| 36 | +``` |
| 37 | +$ cd osm2rdf |
| 38 | +$ mkdir -p build && cd build |
| 39 | +$ cmake .. |
| 40 | +$ make -j |
| 41 | +``` |
| 42 | +Fetch an OSM input file and print TTL to stdout: |
| 43 | +``` |
| 44 | +$ wget https://download.geofabrik.de/europe/germany/baden-wuerttemberg/freiburg-regbez-latest.osm.pbf |
| 45 | +$ ./apps/osm2rdf freiburg-regbex-latest.osm.pbf |
48 | 46 | ``` |
49 | | -$ mkdir input |
50 | | -$ mkdir output |
51 | | -$ mkdir scratch |
52 | 47 |
|
53 | | -$ docker build -t osm2rdf . |
| 48 | +For more options, see `--help`, `-h`, `-hh`, and `-hhh`. |
54 | 49 |
|
55 | | -$ wget -O ./input/germany-latest.osm.pbf https://download.geofabrik.de/europe/germany-latest.osm.pbf |
56 | | -$ docker run --rm -v `pwd`/input/:/input/ -v `pwd`/output/:/output/ -v `pwd`/scratch/:/scratch/ -it osm2rdf /input/germany-latest.osm.pbf -o /output/germany-latest.osm.ttl -t /scratch/ |
57 | | -``` |
58 | 50 |
|
59 | | -### Without Docker |
| 51 | +## Docker |
60 | 52 |
|
61 | | -On Ubuntu 20.04 the following packages are required to build osm2rdf: |
| 53 | +Alternatively you may use the provided `Dockerfile` to compile and run `osm2rdf`: |
62 | 54 | ``` |
63 | | -clang clang-tidy g++ libboost-dev libboost-serialization-dev libexpat1-dev cmake libbz2-dev zlib1g-dev libomp-dev |
| 55 | +$ docker build -t osm2rdf . |
64 | 56 | ``` |
65 | | -`clang` is optional, but without it `clang-tidy` has [unrelated error messages](https://stackoverflow.com/a/52728225). |
66 | 57 |
|
67 | | -Clone and build `osm2rdf`: |
68 | | -``` |
69 | | -$ git clone https://github.com/ad-freiburg/osm2rdf.git |
70 | | -$ cd osm2rdf |
71 | | -$ mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make -j4 && cd .. |
72 | | -``` |
73 | | -Prepare `input`, `output` and `scratch` folders and download some data and convert the data to `ttl`: |
74 | 58 | ``` |
75 | 59 | $ mkdir input |
76 | | -$ mkdir output |
77 | | -$ mkdir scratch |
78 | | -$ wget -O ./input/freiburg-regbez-latest.osm.pbf https://download.geofabrik.de/europe/germany/baden-wuerttemberg/freiburg-regbez-latest.osm.pbf |
79 | | -$ ./build/osm2rdf ./input/freiburg-regbez-latest.osm.pbf -o ./output/freiburg-regbez-latest.osm.ttl |
| 60 | +$ wget -O input/freiburg-regbez-latest.osm.pbf https://download.geofabrik.de/europe/germany/baden-wuerttemberg/freiburg-regbez-latest.osm.pbf |
| 61 | +$ docker run -v `pwd`/input/:/input/ -it osm2rdf /input/freiburg-regbex-latest.osm.pbf |
80 | 62 | ``` |
81 | | - |
82 | | -More `.pbf` files can be found on the [Geofabrik Download Server](https://download.geofabrik.de/index.html) |
0 commit comments