{"id":21235980,"url":"https://github.com/lddl/osm2ch","last_synced_at":"2025-10-09T20:42:36.320Z","repository":{"id":42048029,"uuid":"279514873","full_name":"LdDl/osm2ch","owner":"LdDl","description":"Convert OSM-file to graph for contraction hierarchies","archived":false,"fork":false,"pushed_at":"2023-12-25T11:43:19.000Z","size":17748,"stargazers_count":9,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T15:51:10.318Z","etag":null,"topics":["contraction-hierarchies","dijkstra","dijkstra-algorithm","graph","hacktoberfest","osm","pathfinding","shortest-path-algorithm","shortest-paths","turn-restrictions"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LdDl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-14T07:31:42.000Z","updated_at":"2025-02-24T03:32:30.000Z","dependencies_parsed_at":"2023-12-05T10:51:10.017Z","dependency_job_id":"0c41e2a4-8314-40ee-8a23-98bc75eb8cb5","html_url":"https://github.com/LdDl/osm2ch","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/LdDl/osm2ch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fosm2ch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fosm2ch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fosm2ch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fosm2ch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LdDl","download_url":"https://codeload.github.com/LdDl/osm2ch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fosm2ch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264619109,"owners_count":23638407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contraction-hierarchies","dijkstra","dijkstra-algorithm","graph","hacktoberfest","osm","pathfinding","shortest-path-algorithm","shortest-paths","turn-restrictions"],"created_at":"2024-11-21T00:05:28.706Z","updated_at":"2025-10-09T20:42:31.298Z","avatar_url":"https://github.com/LdDl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/LdDl/osm2ch?status.svg)](https://godoc.org/github.com/LdDl/osm2ch)\n[![Build Status](https://travis-ci.com/LdDl/osm2ch.svg?branch=master)](https://travis-ci.com/LdDl/osm2ch)\n[![Sourcegraph](https://sourcegraph.com/github.com/LdDl/osm2ch/-/badge.svg)](https://sourcegraph.com/github.com/LdDl/osm2ch?badge)\n[![Go Report Card](https://goreportcard.com/badge/github.com/LdDl/osm2ch)](https://goreportcard.com/report/github.com/LdDl/osm2ch)\n[![GitHub tag](https://img.shields.io/github/tag/LdDl/osm2ch.svg)](https://github.com/LdDl/osm2ch/releases)\n# osm2ch\n## Convert *.osm.pbf files to CSV for [contraction hierarchies library](https://github.com/LdDl/ch)\n\n- [osm2ch](#osm2ch)\n  - [Convert *.osm.pbf files to CSV for contraction hierarchies library](#convert-osmpbf-files-to-csv-for-contraction-hierarchies-library)\n  - [About](#about)\n  - [Installation](#installation)\n  - [Usage](#usage)\n  - [Example](#example)\n  - [Dependencies](#dependencies)\n  - [License](#license)\n\n## About\nWith this CLI tool you can convert *.osm.pbf (Compressed Open Street Map) file to CSV (Comma-Separated Values) file, which is used in our [contraction hierarchies library].\nWhat it does:\n- Edge expansion (single edge == single vertex);\n- Handles some kind and types of restrictions:\n    - Supported kind of restrictions:\n        - EdgeFrom - NodeVia - EdgeTo.\n    - Supported types of restrictions:\n        - only_left_turn;\n        - only_right_turn;\n        - only_straight_on;\n        - no_left_turn;\n        - no_right_turn;\n        - no_straight_on.\n- Saves CSV file with geom in WKT format;\n- Currently supports tags for 'highway' OSM entity only.\n\nPRs are welcome!\n\n## Installation\n* Via 'go get':\n    ```shell\n    go get github.com/LdDl/osm2ch\n    go install github.com/LdDl/osm2ch/cmd/osm2ch@v1.5.1\n    ```\n    After installation step is complete you can call 'osm2ch' from any place in your system.\n\n* Or download prebuilt binary and make updates in yours PATH environment varibale (both Linux and Windows):\n    * Windows - https://github.com/LdDl/osm2ch/releases/download/v1.5.1/windows-osm2ch.zip\n    * Linux - https://github.com/LdDl/osm2ch/releases/download/v1.5.1/linux-amd64-osm2ch.tar.gz\n\nNote: There is [zlib](https://www.zlib.net/) support in [OSM-pbf parser](https://github.com/paulmach/osm/pull/19).\nIf you do not want use it then disable CGO:\n```shell\nexport CGO_ENABLED=0\n# Then build osm2ch from source\n```\n\n## Usage\n\n```shell\nosm2ch -h\n```\n\nOutput:\n```shell\nUsage of osm2ch:\n  -file string\n        Filename of *.osm.pbf file (it has to be compressed) (default \"my_graph.osm.pbf\")\n  -geomf string\n        Format of output geometry. Expected values: wkt / geojson (default \"wkt\")\n  -out string\n        Filename of 'Comma-Separated Values' (CSV) formatted file (default \"my_graph.csv\")\n        E.g.: if file name is 'map.csv' then 3 files will be produced: 'map.csv' (edges), 'map_vertices.csv', 'map_shortcuts.csv'\n  -tags string\n        Set of needed tags (separated by commas) (default \"motorway,primary,primary_link,road,secondary,secondary_link,residential,tertiary,tertiary_link,unclassified,trunk,trunk_link,motorway_link\")\n  -units string\n        Units of output weights. Expected values: km for kilometers / m for meters (default \"km\")\n  -contract\n        Prepare contraction hierarchies? (default true)\n```\nThe default list of tags is this, since usually these tags are used for routing for personal cars.\n\n\n## Example\nYou can find example file of *.osm.pbf file in nested child [/example_data](/example_data).\n\nIf you want WKT format for output geometry:\n```shell\nosm2ch --file example_data/moscow_center_reduced.osm.pbf --out graph.csv --geomf wkt --units m --tags motorway,primary,primary_link,road,secondary,secondary_link,residential,tertiary,tertiary_link,unclassified,trunk,trunk_link,motorway_link --contract=true\n```\n\nIf you want GeoJSON format for output geometry:\n```shell\nosm2ch --file example_data/moscow_center_reduced.osm.pbf --out graph.csv --geomf geojson --units m --tags motorway,primary,primary_link,road,secondary,secondary_link,residential,tertiary,tertiary_link,unclassified,trunk,trunk_link,motorway_link --contract=true\n```\n\nIf you dont want to prepare contraction hierarchies then:\n```shell\nosm2ch --file example_data/moscow_center_reduced.osm.pbf --out graph.csv --geomf wkt --units m --tags motorway,primary,primary_link,road,secondary,secondary_link,residential,tertiary,tertiary_link,unclassified,trunk,trunk_link,motorway_link --contract=false\n```\n\nAfter that files 'graph.csv', 'graph_vertices.csv', 'graph_shortcuts.csv' will be created (or only 'graph.csv' and 'graph_vertices' if 'contract' flag is set to False).\n\nHeader of edges CSV-file is: `from_vertex_id;to_vertex_id;weight;geom;was_one_way;edge_id;osm_way_from;osm_way_to;osm_way_from_source_node;osm_way_from_target_node;osm_way_to_source_node;osm_way_to_target_node`\n- from_vertex_id - Generated source vertex;\n- to_vertex_id - Generated target vertex;\n- weight - Traveling cost from source to target (actually length of an edge in kilometers/meters);\n- geom - Geometry of edge (Linestring) in WKT or GeoJSON format.\n- was_one_way - Boolean value. When source OSM way was \"one way\" then it's true, otherwise it's false. Might be helpfull for ignore edges with WasOneWay=true when offesting overlapping two-way geometries in some GIS viewer\n- edge_id - ID of generated edge\n- osm_way_from - ID of source OSM Way\n- osm_way_to - ID of target OSM Way\n- osm_way_from_source_node - ID of first OSM Node in source OSM Way\n- osm_way_from_target_node - ID of last OSM Node in source OSM Way\n- osm_way_to_source_node - ID of first OSM Node in target OSM Way\n- osm_way_to_target_node - ID of last OSM Node in target OSM Way\n\nHeader of vertices CSV-file is: vertex_id;order_pos;importance;geom\n- vertex_id - Vertex;\n- order_pos - Order position in contraction hierarchies;\n- importance - Importance of vertex with respect to contraction hierarchies\n- geom - Geometry of vertex (Point) in WKT or GeoJSON format.\n\n[Optional] Header of shortcuts CSV-file is: from_vertex_id;to_vertex_id;weight;via_vertex_id\n- from_vertex_id - Source vertex;\n- to_vertex_id - Target vertex;\n- weight - Traveling cost from source to target (actually length of the shortcut in kilometers/meters);\n- via_vertex_id - ID of vertex through which the shortcut exists\n\nNow you can use this graph in [contraction hierarchies library].\n\n## Dependencies\nThanks to [paulmach](https://github.com/paulmach) for his [OSM-parser](https://github.com/paulmach/osm) written in Go.\n\nPaulmach's license is [here](https://github.com/paulmach/osm/blob/master/LICENSE.md) (it's MIT)\n\n## License\n- Please see [here](LICENSE.md)\n\n[contraction hierarchies library]: (https://github.com/LdDl/ch#ch---contraction-hierarchies)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Fosm2ch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flddl%2Fosm2ch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Fosm2ch/lists"}