-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactored and fixed contraction code * added networkx output * added example for reading networkx file
- Loading branch information
Showing
26 changed files
with
767 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,4 +93,8 @@ ENV/ | |
|
||
|
||
data/ | ||
cover/ | ||
cover/ | ||
|
||
.mypy_cache/ | ||
.pyre/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Shortest Distances Drawing | ||
|
||
This project is a simple example that illustrates how to **generate a PNG image** file that shows the **shortest distances** from a random/central node of a road network to all other nodes. | ||
Below you see an example of how this can look like. The darker the color, the closer it is to the starting node of the shortest path tree: | ||
![Bremen](./bremen.png) | ||
|
||
This example also shows how to use the networkx output of `OSMtoRoadGraph`. | ||
|
||
## How to prepare (create a networkx json file) | ||
|
||
If you already have a `*.json` file you can move to `How to run`. | ||
|
||
1. Download an OSM XML file (e.g., from here http://download.geofabrik.de/europe/germany.html you can download the [.osm.bz2] file) | ||
1. Unzip the file to obtain the pure xml file (e.g., `bremen-latest.osm`) | ||
1. Run `OsmToRoadGraph` by invoking `python3 run.py -f <FILENAME> -n p -c --networkx` (e.g., `python3 run.py -f data/bremen-latest.osm -n p -c --networkx`) | ||
1. This should have created the `*.json` (e.g., `data/bremen-latest.json`) | ||
|
||
## How to run | ||
|
||
1. Make sure you have a `*.json` file (if not, see the section above) | ||
1. Install the dependencies: `pip3 install -r requirements.txt` | ||
1. Invoke this script as follows: | ||
|
||
```bash | ||
python3 shortest-distances-drawing.py -f <INPUT_FILENAME> -o <OUTPUT_FILENAME> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
python3 shortest-distances-drawing.py -f data/bremen-latest.json -o bremen.png | ||
``` | ||
|
||
**That's it**: This should an output picture of the shortest distances of road network of the input OSM file. | ||
|
||
### Further Customizations | ||
|
||
This little script offers some more customization options: | ||
|
||
```bash | ||
Options: | ||
-h, --help show this help message and exit | ||
-f IN_FILENAME, --file=IN_FILENAME | ||
input networkx JSON file | ||
-o OUT_FILENAME, --out=OUT_FILENAME | ||
output png file | ||
-c, --center set this option to compute the shortest distances from | ||
an approximate center node [default: random node] | ||
-m METRIC, --metric=METRIC | ||
metric for the shortest path algorithm. Either | ||
'length' or 'travel-time' [default: travel-time] | ||
--width=WIDTH image width in px [default=1600] | ||
--height=HEIGHT image height in px [default=1200] | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
utm==0.5.0 | ||
Pillow==7.0.0 | ||
tqdm==4.46.0 |
Oops, something went wrong.