Skip to content

Commit

Permalink
Use Bremen, Germany as example in SETUP_DATABASE
Browse files Browse the repository at this point in the history
  • Loading branch information
codesoap committed Oct 1, 2020
1 parent 9b063ba commit 13b3c5e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions SETUP_DATABASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ psql -d gis -c 'CREATE EXTENSION postgis;'
```

# Filling the database with osm data
Use one of the following two code blocks to get started. When everything
Use one of the following two code blocks to get started; the examles
in the README file works for `bremen-latest.osm.pbf`. When everything
worked out, you can start playing around with bigger `*.pbf` files,
like Sweden, the USA or even the whole planet. You can find those at
[download.geofabrik.de](https://download.geofabrik.de) and
like Sweden, the USA or even the whole planet. You can find those
at [download.geofabrik.de](https://download.geofabrik.de) and
[planet.osm.org](https://planet.osm.org).

Azores (nice and small; good for quick testing):
Bremen, Germany (nice and small; good for quick testing):
```bash
wget 'https://download.geofabrik.de/europe/azores-latest.osm.pbf'
wget 'https://download.geofabrik.de/europe/germany/bremen-latest.osm.pbf'

# Takes ~30s; turns the ~10MB *.pbf file into a ~300MB database:
osm2pgsql --create --database gis azores-latest.osm.pbf
# Takes ~40s; turns the ~16.5MB *.pbf file into a ~265MB database:
osm2pgsql --create --database gis bremen-latest.osm.pbf
```

Serbia (a little bigger, but still good for testing on a simple laptop):
Expand All @@ -61,18 +62,18 @@ ones. Enter these into a PostreSQL shell. Such a shell can be opened
with `psql -d gis`. Make sure the PostreSQL server is running
(`postgres -d data`).

Finding cinemas in Belgrade:
```sql
SELECT osm_id, name FROM planet_osm_point
WHERE amenity = 'cinema'
AND way && ST_Transform(ST_GeomFromText('POLYGON((20.3 44.9, 20.3 44.7, 20.6 44.7, 20.6 44.9, 20.3 44.9))', 4326), 3857);
```

Finding bicycle shops with coordinates in a part of Bremen:
```sql
SELECT osm_id, name, ST_AsText(ST_Transform(way, 4326)) FROM planet_osm_point
WHERE shop = 'bicycle'
AND way && ST_Transform(ST_GeomFromText('POLYGON((8.7968 53.1037, 8.8142 53.1037, 8.8142 53.0834, 8.7968 53.0834, 8.7968 53.1037))', 4326), 3857);
```

Finding cinemas in Belgrade:
```sql
SELECT osm_id, name FROM planet_osm_point
WHERE amenity = 'cinema'
AND way && ST_Transform(ST_GeomFromText('POLYGON((20.3 44.9, 20.3 44.7, 20.6 44.7, 20.6 44.9, 20.3 44.9))', 4326), 3857);
```

Schema reference: https://wiki.openstreetmap.org/wiki/Osm2pgsql/schema

0 comments on commit 13b3c5e

Please sign in to comment.