scgraph 2.8.2__tar.gz → 2.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {scgraph-2.8.2/scgraph.egg-info → scgraph-2.9.0}/PKG-INFO +69 -1
  2. {scgraph-2.8.2 → scgraph-2.9.0}/README.md +68 -0
  3. {scgraph-2.8.2 → scgraph-2.9.0}/pyproject.toml +1 -1
  4. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/__init__.py +68 -0
  5. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/geograph.py +408 -145
  6. scgraph-2.9.0/scgraph/helpers/geojson.py +162 -0
  7. scgraph-2.9.0/scgraph/helpers/visvalingam.py +135 -0
  8. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/utils.py +19 -0
  9. {scgraph-2.8.2 → scgraph-2.9.0/scgraph.egg-info}/PKG-INFO +69 -1
  10. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph.egg-info/SOURCES.txt +3 -1
  11. {scgraph-2.8.2 → scgraph-2.9.0}/setup.cfg +1 -1
  12. {scgraph-2.8.2 → scgraph-2.9.0}/LICENSE +0 -0
  13. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/cache.py +0 -0
  14. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/core.py +0 -0
  15. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/geographs/__init__.py +0 -0
  16. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/geographs/marnet.py +0 -0
  17. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/geographs/north_america_rail.py +0 -0
  18. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/geographs/oak_ridge_maritime.py +0 -0
  19. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/geographs/us_freeway.py +0 -0
  20. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/graph.py +0 -0
  21. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/grid.py +0 -0
  22. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/helpers/__init__.py +0 -0
  23. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/helpers/shape_mover_utils.py +0 -0
  24. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph/spanning.py +0 -0
  25. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph.egg-info/dependency_links.txt +0 -0
  26. {scgraph-2.8.2 → scgraph-2.9.0}/scgraph.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scgraph
3
- Version: 2.8.2
3
+ Version: 2.9.0
4
4
  Summary: Determine an approximate route between two points on earth.
5
5
  Author-email: Connor Makowski <conmak@mit.edu>
6
6
  Project-URL: Homepage, https://github.com/connor-makowski/scgraph
@@ -258,6 +258,74 @@ output = marnet_geograph.get_shortest_path(
258
258
  get_line_path(output, filename='output.geojson')
259
259
  ```
260
260
 
261
+ ### Building your own Geographs from Open Source Data
262
+ You can build your own geographs using various tools and data sources. For example, you can use OpenStreetMap data to create a high fidelity geograph for a specific area.
263
+
264
+ Expand the secion below for a step by step guide on how to create a geograph from OpenStreetMap data.
265
+ <details>
266
+ <summary>Click to see an example for Michigan, USA</summary>
267
+
268
+ For this example, we will use some various tools to create a geograph for highways (including seconday highways) in Michigan, USA.
269
+
270
+ Download an OSM PBF file using the AWS CLI:
271
+ - Geofabrik is a good source for smaller OSM PBF files. See: https://download.geofabrik.de/
272
+ - To keep things generalizable, you can also download the entire planet OSM PBF file using AWS. But you should consider downloading a smaller region if you are only interested in a specific area.
273
+ - Note: For this, you will need to install the AWS CLI.
274
+ - Note: The planet OSM PBF file is very large (About 100GB)
275
+ ```
276
+ aws s3 cp s3://osm-pds/planet-latest.osm.pbf .
277
+ ```
278
+ - Use Osmium to filter and extract the highways from the OSM PBF file.
279
+ - Install osmium on macOS:
280
+ ```
281
+ brew install osmium-tool
282
+ ```
283
+ - Install osmium on Ubuntu:
284
+ ```
285
+ sudo apt-get install osmium-tool
286
+ ```
287
+ - Download a Poly file for the area you are interested in. This is a polygon file that defines the area you want to extract from the OSM PBF file.
288
+ - For Michigan, you can download the poly file from Geofabrik:
289
+ ```
290
+ curl https://download.geofabrik.de/north-america/us/michigan.poly > michigan.poly
291
+ ```
292
+ - Google around to find an appropriate poly file for your area of interest.
293
+ - Filter and extract as GeoJSON (EG: Michigan) substituting the poly and pbf file names as needed:
294
+ ```
295
+ osmium extract -p michigan.poly --overwrite -o michigan.osm.pbf planet-latest.osm.pbf
296
+ ```
297
+ - Filter the OSM PBF file to only areas of interest and export to GeoJSON:
298
+ - See: https://wiki.openstreetmap.org/wiki/
299
+ - EG For Highways, see: https://wiki.openstreetmap.org/wiki/Key:highway
300
+ ```
301
+ osmium tags-filter michigan.osm.pbf w/highway=motorway,trunk,primary,motorway_link,trunk_link,primary_link,secondary,secondary_link,tertiary,tertiary_link -t --overwrite -o michigan_roads.osm.pbf
302
+ osmium export michigan_roads.osm.pbf -f geojson --overwrite -o michigan_roads.geojson
303
+ ```
304
+
305
+ - Simplify the geojson
306
+ - This uses some tools in the SCGraph library as well as Mapshaper to simplify the geojson files.
307
+ - Mapshaper is a CLI and web tool for simplifying and editing geojson files.
308
+ - To install Mapshaper for CLI use, use NPM:
309
+ ```
310
+ npm install -g mapshaper
311
+ ```
312
+ - Mapshaper is particularly helpful since it repairs intersections in the lines which is crutial for geographs to work properly.
313
+ - Mapshaper, however, does not handle larger files very well, so it is recommended to simplify the geojson file first using the `scgraph.helpers.geojson.simplify_geojson` function first to reduce the size of the file.
314
+ - Make sure to tailor the parameters to your needs.
315
+ ```
316
+ python -c "from scgraph.helpers.geojson import simplify_geojson; simplify_geojson('michigan_roads.geojson', 'michigan_roads_simple.geojson', precision=4, pct_to_keep=100, min_points=3, silent=False)"
317
+ mapshaper michigan_roads_simple.geojson -simplify 10% -filter-fields -o force michigan_roads_simple.geojson
318
+ mapshaper michigan_roads_simple.geojson -snap -clean -o force michigan_roads_simple.geojson
319
+ ```
320
+ - Load the newly created geojson file as a geograph:
321
+ - Note: The `GeoGraph.load_from_geojson` function is used to load the geojson file as a geograph.
322
+ - This will create a geograph that can be used to calculate shortest paths between points on the graph.
323
+ ```
324
+ from scgraph import GeoGraph
325
+ michigan_roads_geograph = GeoGraph.load_from_geojson('michigan_roads_simple.geojson')
326
+ ```
327
+ </details>
328
+
261
329
  ### Custom Graphs and Geographs
262
330
  Modify an existing geograph: See the notebook [here](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
263
331
 
@@ -242,6 +242,74 @@ output = marnet_geograph.get_shortest_path(
242
242
  get_line_path(output, filename='output.geojson')
243
243
  ```
244
244
 
245
+ ### Building your own Geographs from Open Source Data
246
+ You can build your own geographs using various tools and data sources. For example, you can use OpenStreetMap data to create a high fidelity geograph for a specific area.
247
+
248
+ Expand the secion below for a step by step guide on how to create a geograph from OpenStreetMap data.
249
+ <details>
250
+ <summary>Click to see an example for Michigan, USA</summary>
251
+
252
+ For this example, we will use some various tools to create a geograph for highways (including seconday highways) in Michigan, USA.
253
+
254
+ Download an OSM PBF file using the AWS CLI:
255
+ - Geofabrik is a good source for smaller OSM PBF files. See: https://download.geofabrik.de/
256
+ - To keep things generalizable, you can also download the entire planet OSM PBF file using AWS. But you should consider downloading a smaller region if you are only interested in a specific area.
257
+ - Note: For this, you will need to install the AWS CLI.
258
+ - Note: The planet OSM PBF file is very large (About 100GB)
259
+ ```
260
+ aws s3 cp s3://osm-pds/planet-latest.osm.pbf .
261
+ ```
262
+ - Use Osmium to filter and extract the highways from the OSM PBF file.
263
+ - Install osmium on macOS:
264
+ ```
265
+ brew install osmium-tool
266
+ ```
267
+ - Install osmium on Ubuntu:
268
+ ```
269
+ sudo apt-get install osmium-tool
270
+ ```
271
+ - Download a Poly file for the area you are interested in. This is a polygon file that defines the area you want to extract from the OSM PBF file.
272
+ - For Michigan, you can download the poly file from Geofabrik:
273
+ ```
274
+ curl https://download.geofabrik.de/north-america/us/michigan.poly > michigan.poly
275
+ ```
276
+ - Google around to find an appropriate poly file for your area of interest.
277
+ - Filter and extract as GeoJSON (EG: Michigan) substituting the poly and pbf file names as needed:
278
+ ```
279
+ osmium extract -p michigan.poly --overwrite -o michigan.osm.pbf planet-latest.osm.pbf
280
+ ```
281
+ - Filter the OSM PBF file to only areas of interest and export to GeoJSON:
282
+ - See: https://wiki.openstreetmap.org/wiki/
283
+ - EG For Highways, see: https://wiki.openstreetmap.org/wiki/Key:highway
284
+ ```
285
+ osmium tags-filter michigan.osm.pbf w/highway=motorway,trunk,primary,motorway_link,trunk_link,primary_link,secondary,secondary_link,tertiary,tertiary_link -t --overwrite -o michigan_roads.osm.pbf
286
+ osmium export michigan_roads.osm.pbf -f geojson --overwrite -o michigan_roads.geojson
287
+ ```
288
+
289
+ - Simplify the geojson
290
+ - This uses some tools in the SCGraph library as well as Mapshaper to simplify the geojson files.
291
+ - Mapshaper is a CLI and web tool for simplifying and editing geojson files.
292
+ - To install Mapshaper for CLI use, use NPM:
293
+ ```
294
+ npm install -g mapshaper
295
+ ```
296
+ - Mapshaper is particularly helpful since it repairs intersections in the lines which is crutial for geographs to work properly.
297
+ - Mapshaper, however, does not handle larger files very well, so it is recommended to simplify the geojson file first using the `scgraph.helpers.geojson.simplify_geojson` function first to reduce the size of the file.
298
+ - Make sure to tailor the parameters to your needs.
299
+ ```
300
+ python -c "from scgraph.helpers.geojson import simplify_geojson; simplify_geojson('michigan_roads.geojson', 'michigan_roads_simple.geojson', precision=4, pct_to_keep=100, min_points=3, silent=False)"
301
+ mapshaper michigan_roads_simple.geojson -simplify 10% -filter-fields -o force michigan_roads_simple.geojson
302
+ mapshaper michigan_roads_simple.geojson -snap -clean -o force michigan_roads_simple.geojson
303
+ ```
304
+ - Load the newly created geojson file as a geograph:
305
+ - Note: The `GeoGraph.load_from_geojson` function is used to load the geojson file as a geograph.
306
+ - This will create a geograph that can be used to calculate shortest paths between points on the graph.
307
+ ```
308
+ from scgraph import GeoGraph
309
+ michigan_roads_geograph = GeoGraph.load_from_geojson('michigan_roads_simple.geojson')
310
+ ```
311
+ </details>
312
+
245
313
  ### Custom Graphs and Geographs
246
314
  Modify an existing geograph: See the notebook [here](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
247
315
 
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "scgraph"
15
- version = "2.8.2"
15
+ version = "2.9.0"
16
16
  description = "Determine an approximate route between two points on earth."
17
17
  authors = [
18
18
  {name="Connor Makowski", email="conmak@mit.edu"}
@@ -243,6 +243,74 @@ output = marnet_geograph.get_shortest_path(
243
243
  get_line_path(output, filename='output.geojson')
244
244
  ```
245
245
 
246
+ ### Building your own Geographs from Open Source Data
247
+ You can build your own geographs using various tools and data sources. For example, you can use OpenStreetMap data to create a high fidelity geograph for a specific area.
248
+
249
+ Expand the secion below for a step by step guide on how to create a geograph from OpenStreetMap data.
250
+ <details>
251
+ <summary>Click to see an example for Michigan, USA</summary>
252
+
253
+ For this example, we will use some various tools to create a geograph for highways (including seconday highways) in Michigan, USA.
254
+
255
+ Download an OSM PBF file using the AWS CLI:
256
+ - Geofabrik is a good source for smaller OSM PBF files. See: https://download.geofabrik.de/
257
+ - To keep things generalizable, you can also download the entire planet OSM PBF file using AWS. But you should consider downloading a smaller region if you are only interested in a specific area.
258
+ - Note: For this, you will need to install the AWS CLI.
259
+ - Note: The planet OSM PBF file is very large (About 100GB)
260
+ ```
261
+ aws s3 cp s3://osm-pds/planet-latest.osm.pbf .
262
+ ```
263
+ - Use Osmium to filter and extract the highways from the OSM PBF file.
264
+ - Install osmium on macOS:
265
+ ```
266
+ brew install osmium-tool
267
+ ```
268
+ - Install osmium on Ubuntu:
269
+ ```
270
+ sudo apt-get install osmium-tool
271
+ ```
272
+ - Download a Poly file for the area you are interested in. This is a polygon file that defines the area you want to extract from the OSM PBF file.
273
+ - For Michigan, you can download the poly file from Geofabrik:
274
+ ```
275
+ curl https://download.geofabrik.de/north-america/us/michigan.poly > michigan.poly
276
+ ```
277
+ - Google around to find an appropriate poly file for your area of interest.
278
+ - Filter and extract as GeoJSON (EG: Michigan) substituting the poly and pbf file names as needed:
279
+ ```
280
+ osmium extract -p michigan.poly --overwrite -o michigan.osm.pbf planet-latest.osm.pbf
281
+ ```
282
+ - Filter the OSM PBF file to only areas of interest and export to GeoJSON:
283
+ - See: https://wiki.openstreetmap.org/wiki/
284
+ - EG For Highways, see: https://wiki.openstreetmap.org/wiki/Key:highway
285
+ ```
286
+ osmium tags-filter michigan.osm.pbf w/highway=motorway,trunk,primary,motorway_link,trunk_link,primary_link,secondary,secondary_link,tertiary,tertiary_link -t --overwrite -o michigan_roads.osm.pbf
287
+ osmium export michigan_roads.osm.pbf -f geojson --overwrite -o michigan_roads.geojson
288
+ ```
289
+
290
+ - Simplify the geojson
291
+ - This uses some tools in the SCGraph library as well as Mapshaper to simplify the geojson files.
292
+ - Mapshaper is a CLI and web tool for simplifying and editing geojson files.
293
+ - To install Mapshaper for CLI use, use NPM:
294
+ ```
295
+ npm install -g mapshaper
296
+ ```
297
+ - Mapshaper is particularly helpful since it repairs intersections in the lines which is crutial for geographs to work properly.
298
+ - Mapshaper, however, does not handle larger files very well, so it is recommended to simplify the geojson file first using the `scgraph.helpers.geojson.simplify_geojson` function first to reduce the size of the file.
299
+ - Make sure to tailor the parameters to your needs.
300
+ ```
301
+ python -c "from scgraph.helpers.geojson import simplify_geojson; simplify_geojson('michigan_roads.geojson', 'michigan_roads_simple.geojson', precision=4, pct_to_keep=100, min_points=3, silent=False)"
302
+ mapshaper michigan_roads_simple.geojson -simplify 10% -filter-fields -o force michigan_roads_simple.geojson
303
+ mapshaper michigan_roads_simple.geojson -snap -clean -o force michigan_roads_simple.geojson
304
+ ```
305
+ - Load the newly created geojson file as a geograph:
306
+ - Note: The `GeoGraph.load_from_geojson` function is used to load the geojson file as a geograph.
307
+ - This will create a geograph that can be used to calculate shortest paths between points on the graph.
308
+ ```
309
+ from scgraph import GeoGraph
310
+ michigan_roads_geograph = GeoGraph.load_from_geojson('michigan_roads_simple.geojson')
311
+ ```
312
+ </details>
313
+
246
314
  ### Custom Graphs and Geographs
247
315
  Modify an existing geograph: See the notebook [here](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
248
316