Skip to content

Commit e0dc67e

Browse files
committed
2 parents 09cbab6 + ec92f0f commit e0dc67e

File tree

8 files changed

+255
-24
lines changed

8 files changed

+255
-24
lines changed

.circleci/config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/python:2.7.14-stretch
6+
steps:
7+
- checkout
8+
- run:
9+
name: Installing OSM dependencies
10+
command: sudo apt-get install osmosis osmctools
11+
- run:
12+
name: Installing Python package and dependencies
13+
command: pip install --user .
14+
- run:
15+
name: Running tests
16+
command: python setup.py test

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# http://editorconfig.org
2+
3+
# based on https://github.com/django/django/blob/master/.editorconfig
4+
5+
root = true
6+
7+
[*]
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
end_of_line = lf
12+
charset = utf-8
13+
14+
# Docstrings and comments use max_line_length = 79
15+
[*.py]
16+
max_line_length = 119
17+
indent_size = 4
18+
19+
[*.rb]
20+
indent_size = 2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ target/
6060
# Virtual Environment
6161
venv/
6262
data
63+
64+
# PyTest
65+
.pytest_cache/

README.md

Lines changed: 197 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,205 @@
1-
[![current release version](https://img.shields.io/github/release/interline-io/osm-planet-update.svg)](https://github.com/interline-io/osm-planet-update/releases)
2-
[![Docker Hub build status](https://img.shields.io/docker/build/interline/osm-planet-update.svg)](https://hub.docker.com/r/interline/osm-planet-update/)
1+
[![current release version](https://img.shields.io/github/release/interline-io/planetutils.svg)](https://github.com/interline-io/planetutils/releases)
2+
[![Docker Hub container image build status](https://img.shields.io/docker/build/interline/planetutils.svg)](https://hub.docker.com/r/interline/planetutils/)
3+
[![CircleCI code test status](https://circleci.com/gh/interline-io/planetutils.svg?style=svg)](https://circleci.com/gh/interline-io/planetutils)
34

4-
# OSM Planet Update Tools
5+
# Interline PlanetUtils
56

6-
Scripts and a Docker container to maintain your own mirror of the [OpenStreetMap](http://www.openstreetmap.org) planet.
7+
<!-- the following is generated by:
8+
1. npm install --save markdown-toc -g
9+
2. markdown-toc -i README.md
10+
-->
11+
12+
<!-- toc -->
13+
14+
- [Features](#features)
15+
- [Installation](#installation)
16+
* [Using Docker container](#using-docker-container)
17+
* [Using Homebrew on Mac OS](#using-homebrew-on-mac-os)
18+
* [Using Python package](#using-python-package)
19+
- [Usage](#usage)
20+
* [osm_planet_update](#osm_planet_update)
21+
* [osm_planet_extract](#osm_planet_extract)
22+
* [elevation_tile_download](#elevation_tile_download)
23+
* [Bounding box CSV file format](#bounding-box-csv-file-format)
24+
- [Support](#support)
25+
26+
<!-- tocstop -->
27+
28+
## Features
29+
30+
Python-based scripts and a Docker container to work with planet-scale geographic data. Using PlanetUtils, you can:
31+
32+
- maintain your own copy of the [OpenStreetMap](http://www.openstreetmap.org) planet (by applying incremental updates)
33+
- cut your copy of the OSM planet into named bounding boxes (a.k.a., mini Mapzen Metro Extracts)
34+
- download [Mapzen Terrain Tiles from AWS](https://aws.amazon.com/public-datasets/terrain/) for the planet or your bounding boxes
35+
36+
PlanetUtils is packaged for use as a:
37+
38+
- Docker container, for use on any operating system
39+
- Python package, for use on any operating system
40+
- Homebrew formula, for use on Mac OS
41+
42+
## Installation
43+
44+
### Using Docker container
45+
46+
Make sure you have [Docker](https://www.docker.com/community-edition) installed. Then:
47+
48+
```sh
49+
docker pull interline/planetutils:release-v0.2.0
50+
```
51+
52+
### Using Homebrew on Mac OS
53+
54+
Make sure you have [Homebrew](https://brew.sh/) installed. Then:
55+
56+
```sh
57+
brew install interline-io/planetutils/planetutils
58+
```
59+
60+
### Using Python package
61+
62+
If you want to install and use the Python package directly, you'll need to provide:
63+
64+
- Python 2.x
65+
- Java
66+
- [Osmosis](https://wiki.openstreetmap.org/wiki/Osmosis)
67+
- [OSM C tools](https://gitlab.com/osm-c-tools/osmctools/)
68+
69+
Then clone this repo, run the tests, and install the Python package:
70+
71+
```sh
72+
git clone https://github.com/interline-io/planetutils.git
73+
nosetests
74+
pip install .
75+
```
776

877
## Usage
978

10-
Using [Osmosis](https://wiki.openstreetmap.org/wiki/Osmosis):
79+
PlanetUtils supplies the following command-line utilities:
80+
81+
### osm_planet_update
82+
83+
Update a local OSM planet. For example:
84+
85+
- Using Docker:
86+
```sh
87+
docker run --rm -v ${PWD}/data:/data -t interline/planetutils:release-v0.2.0 osm_planet_update planet-latest.osm.pbf planet-new.osm.pbf
88+
````
89+
- Using Homebrew or Python:
90+
```sh
91+
osm_planet_update planet-latest.osm.pbf planet-new.osm.pbf
92+
```
93+
94+
If `planet-latest.osm.pbf` does not exist, it will be downloaded, before applying updates.
95+
96+
By default, files are downloaded from planet.openstreetmap.org. Amazon Web Services also provides OSM planets through its Public Datasets program. To instead download the planet from AWS:
97+
98+
1. Make sure you have your [AWS credentials configured locally](http://boto3.readthedocs.io/en/latest/guide/configuration.html).
99+
2. Append the `--s3` flag.
100+
101+
Note that an entire OSM planet may be upwards of 40Gb in size!
102+
103+
For complete help on command-line arguments:
11104

12105
```sh
13-
mkdir -p data
14-
docker run --rm -v data:/data -t interline/osm-planet-update:release-v0.1.1
106+
osm_planet_update -h
15107
```
108+
109+
### osm_planet_extract
110+
111+
Cut up an OSM planet file into one or more extracts, defined by bounding boxes. Each bounding box is assigned a name. (This is like a mini version of Mapzen Metro Extracts!)
112+
113+
To create a single extract:
114+
115+
- Using Docker:
116+
```sh
117+
docker run --rm -v ${PWD}/data:/data -t interline/planetutils:release-v0.2.0 osm_planet_extract /data/osm_extracts --bbox=-122.737,37.449,-122.011,37.955 --name=san-francisco
118+
````
119+
- Using Homebrew or Python:
120+
```sh
121+
osm_planet_extract data/osm_extracts --bbox=-122.737,37.449,-122.011,37.955 --name=san-francisco
122+
```
123+
124+
To specify more than one bounding box of tiles to download, list the bounding boxes in a [CSV file](#bounding-box). For example:
125+
126+
- Using Docker:
127+
```sh
128+
docker run --rm -v ${PWD}/data:/data -t interline/planetutils:release-v0.2.0 osm_planet_extract /data/osm_extracts --csv=/data/bboxes.csv
129+
````
130+
- Using Homebrew or Python:
131+
```sh
132+
osm_planet_extract data/osm_extracts --csv=data/bboxes.csv
133+
```
134+
135+
For complete help on command-line arguments:
136+
137+
```sh
138+
osm_planet_extract -h
139+
```
140+
141+
### elevation_tile_download
142+
143+
Download elevation tiles from the [Terrain Tiles in the AWS Public Datasets program](https://aws.amazon.com/public-datasets/terrain/). Download for the entire planet, only tiles within a single bounding box, or within multiple bounding boxes.
144+
145+
To download the entire planet of tiles (__which will require about 1.6Tb of space!__):
146+
147+
- Using Docker:
148+
```sh
149+
docker run --rm -v ${PWD}/data:/data -t interline/planetutils:release-v0.2.0 elevation_tile_download /data/elevation
150+
````
151+
- Using Homebrew or Python:
152+
```sh
153+
elevation_tile_download data/elevation
154+
```
155+
156+
To download tiles to cover a single bounding box:
157+
158+
- Using Docker:
159+
```sh
160+
docker run --rm -v ${PWD}/data:/data -t interline/planetutils:release-v0.2.0 elevation_tile_download /data/elevation --bbox=-122.737,37.449,-122.011,37.955
161+
````
162+
- Using Homebrew or Python:
163+
```sh
164+
elevation_tile_download data/elevation --bbox=-122.737,37.449,-122.011,37.955
165+
```
166+
167+
To specify more than one bounding box of tiles to download, list the bounding boxes in a [CSV file](#bounding-box). For example:
168+
169+
- Using Docker:
170+
```sh
171+
docker run --rm -v ${PWD}/data:/data -t interline/planetutils:release-v0.2.0 elevation_tile_download /data/elevation --csv=/data/bboxes.csv
172+
````
173+
- Using Homebrew or Python:
174+
```sh
175+
elevation_tile_download data/elevation --csv=data/bboxes.csv
176+
```
177+
178+
For complete help on command-line arguments:
179+
180+
```sh
181+
elevation_tile_download -h
182+
```
183+
184+
### Bounding box CSV file format
185+
<a name="bounding-box"></a>
186+
187+
When extracting multiple bounding boxes from an OSM planet, or when downloading multiple bounding boxes of elevation tiles, you can specify your bounding boxes in a single CSV file. Do not include a header row. The format is as follows:
188+
189+
```csv
190+
[name for extract],[left longitude],[bottom latitude],[right longitude],[top latitude]
191+
```
192+
193+
For example:
194+
```csv
195+
san-francisco,-122.737,37.449,-122.011,37.955
196+
dar-es-salaam,38.894,-7.120,39.661,-6.502
197+
```
198+
199+
To determine a bounding box, try the tool at http://bboxfinder.com/
200+
201+
## Support
202+
203+
To report a bug, please [open an issue](https://github.com/interline-io/planetutils).
204+
205+
Interline Technologies also provides professional support and consulting services around this and other related tools. Contact us at info@interline.io for more information.

planetutils/elevation_download.py renamed to planetutils/elevation_tile_download.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
def main():
88
parser = argparse.ArgumentParser()
9-
parser.add_argument('outpath', help='output path')
10-
parser.add_argument('--csv', help='csv path with bbox definitions')
11-
parser.add_argument('--bbox', help='bbox as (left,bottom,right,top)')
9+
parser.add_argument('outpath', help='Output path for elevation tiles.')
10+
parser.add_argument('--csv', help='Path to CSV file with bounding box definitions.')
11+
parser.add_argument('--bbox', help='Bounding box for extract file. Format for coordinates: left,bottom,right,top')
1212
args = parser.parse_args()
1313
p = ElevationDownloader(args.outpath)
1414
if args.csv:

planetutils/planet_extract.py renamed to planetutils/osm_planet_extract.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
def main():
77
parser = argparse.ArgumentParser()
8-
parser.add_argument('osmpath', help='osm path')
9-
parser.add_argument('--csv', help='csv path with bbox definitions')
10-
parser.add_argument('--name', help='extract name')
11-
parser.add_argument('--bbox', help='bbox as (left,bottom,right,top)')
8+
parser.add_argument('osmpath', help='Name or path to OSM planet file. Use planet_update if you do not have a copy locally.')
9+
parser.add_argument('--csv', help='Path to CSV file with bounding box definitions.')
10+
parser.add_argument('--name', help='Name to give to extract file.')
11+
parser.add_argument('--bbox', help='Bounding box for extract file. Format for coordinates: left,bottom,right,top')
1212
args = parser.parse_args()
1313
p = Planet(args.osmpath)
1414
if args.csv:

planetutils/planet_update.py renamed to planetutils/osm_planet_update.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
def main():
66
parser = argparse.ArgumentParser()
7-
parser.add_argument('osmpath', help='osm path')
8-
parser.add_argument('outpath', help='output path')
9-
parser.add_argument('--s3', action='store_true', help='download using s3 from osm-pds')
7+
parser.add_argument('osmpath', help='Name or path to existing OSM planet file. Will be created and downloaded, if it does not exist.')
8+
parser.add_argument('outpath', help='Name or path to where updated output file should be placed.')
9+
parser.add_argument('--s3', action='store_true', help='Download using S3 client from AWS Public Datasets program. AWS credentials required.')
1010
args = parser.parse_args()
1111
if not os.path.exists(args.osmpath):
1212
print "planet does not exist; downloading"

setup.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
long_description = f.read()
1010

1111
setup(name='interline-planetutils',
12-
version='0.1',
13-
description='Interline Planet Utilities',
12+
version='0.2.0',
13+
description='Interline PlanetUtils',
1414
long_description=long_description,
15-
url='https://github.com/interline-io/osm-planet-update',
15+
url='https://github.com/interline-io/planetutils',
1616
author='Ian Rees',
1717
author_email='ian@interline.io',
1818
license='MIT',
1919
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
20-
install_requires=['boto3', 'nose'],
20+
install_requires=['boto3'],
21+
tests_require=['nose'],
22+
test_suite = 'nose.collector',
2123
entry_points={
2224
'console_scripts': [
23-
'planet_update=planetutils.planet_update:main',
24-
'planet_extract=planetutils.planet_extract:main',
25-
'elevation_download=planetutils.elevation_download:main'
25+
'osm_planet_update=planetutils.osm_planet_update:main',
26+
'osm_planet_extract=planetutils.osm_planet_extract:main',
27+
'elevation_tile_download=planetutils.elevation_download:main'
2628
],
2729
},
2830
classifiers=[

0 commit comments

Comments
 (0)