Skip to content

Commit

Permalink
Readme add geojson info (#24)
Browse files Browse the repository at this point in the history
* added example of geojson to readme
  • Loading branch information
AndGem authored May 13, 2021
1 parent 80b5277 commit 696be90
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["Andreas <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "2.33.3"
geojson = { version = "0.22.0", features=["geo-types"] }
Expand Down
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The main question it answers is: How do I extract the polygon of an administrati

In particular it looks for administrative boundaries (e.g., city boundaries, country boundaries, ...) and creates an output file per boundary that is in the [Osmosis Polygon format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format).

Since version `0.3.0` it also supports the [GeoJSON](https://geojson.org/) output format.
Since version `0.3.0` it also supports the [GeoJson](https://geojson.org/) output format.

## Download

Expand All @@ -26,7 +26,7 @@ USAGE:
osm_extract_polygon [FLAGS] [OPTIONS] --file <filename>

FLAGS:
-g, --geojson set this flag to generate geojson output
-g, --geojson set this flag to generate GeoJson output
-o, --overwrite set this flag to overwrite files without asking; if neither this nor --skip is set the user is
being prompted should a file be overwritten.
-s, --skip set this flag to skip overwriting files; if neither this nor --overwrite is set the user is being
Expand All @@ -40,7 +40,7 @@ OPTIONS:
-m, --min <min_admin_level> minimum administrative level (can take value from 1-11) [default: 8]
```
### Example
### Example 1 - Simple use case
```sh
osm_extract_polygon -f karlsruhe-regbez-latest.osm.pbf
Expand All @@ -54,6 +54,57 @@ Should more than one administrative boundary result in the same name, then, to a
For more information about the meaning of the minimum and maximum administrative level take a look into the [OSM Wiki](https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative).
### Example 2 - GeoJson Output
In the next example we will create, additionally to the `*.poly` output, also matching GeoJSON files. We do this by passing the command line parameter `--geojson` (or alternatively, the short form `-g`) to the program.
```sh
./osm_extract_polygon -f berlin-latest.osm.pbf --geojson -o
```
This should create additional GeoJson files in the subfolder `berlin-latest.osm.pbf_polygons/`. Note, that we have also passed the parameter `-o` which instructs the program to overwrite already existing files in this folder without asking.
Example GeoJson file in the output:
```json
{
"geometry": {
"coordinates": [
[
[
[
13.441906929016113,
52.3632698059082
],
[
13.440044403076172,
52.363494873046875
],
[
13.437420845031738,
52.36367416381836
],
[
13.437135696411133,
52.36361312866211
],
[
13.436691284179688,
52.36356735229492
],
...
]
]
],
"type": "Polygon"
},
"properties": {
"name": "Blankenfelde-Mahlow"
},
"type": "Feature"
}
```
## Use Case: Extracting a smaller OSM file of a city
Assume you want to have a small OSM file of a single city.
Expand Down

0 comments on commit 696be90

Please sign in to comment.