-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polish mwe.py and make it more user-friendly
- Loading branch information
Showing
1 changed file
with
19 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,32 @@ | ||
"""Minimum working example for superblockify.""" | ||
|
||
from superblockify import ResidentialPartitioner | ||
# While this script is running, figures will be generated on screen. | ||
# Close the figure windows to proceed with the script execution. | ||
|
||
|
||
from superblockify import ResidentialPartitioner | ||
|
||
if __name__ == "__main__": | ||
part = ResidentialPartitioner( | ||
name="Salerno_mwe", | ||
city_name="Salerno", | ||
search_str="Salern, Campania, Italy", | ||
# reload_graph=True | ||
# --- Initialize the partitioner --- | ||
partitioner = ResidentialPartitioner( | ||
name="Scheveningen_test", | ||
city_name="Scheveningen", | ||
search_str="Scheveningen, NL", | ||
unit="time", # "time", "distance", any other edge attribute, or None to count edges | ||
) | ||
# Find search strings via https://nominatim.openstreetmap.org/ | ||
# The smaller the place, the quicker the partitioning | ||
# For large places sufficient memory is required | ||
# If you want to select a different city, find the corresponding search string | ||
# (`search_str`) at https://nominatim.openstreetmap.org/. | ||
# The smaller the place, the quicker the partitioning. | ||
# For large places sufficient memory is required. | ||
|
||
# Save the preprocessed graph to disk: | ||
# >>> part.save(save_graph_copy=True) | ||
# If loading a previously saved graph, all previous steps are not needed: | ||
# >>> part = ResidentialPartitioner.load("Salerno_mwe") | ||
|
||
part.run( | ||
# --- Run the partitioner --- | ||
partitioner.run( | ||
calculate_metrics=True, | ||
make_plots=True, | ||
replace_max_speeds=False, | ||
) | ||
|
||
# Save the partitioner to disk, with all attributes, without an extra copy of the | ||
# --- Save the partitioner --- | ||
# Save it to disk, with all attributes, without an extra copy of the | ||
# graph. The original graph has been cached in the data/graphs folder. | ||
part.save() | ||
|
||
# or | ||
# >>> import superblockify as sb | ||
# >>> part = sb.ResidentialPartitioner(...) | ||
# >>> part.run(...) | ||
# >>> sb.save_to_gpkg(part) | ||
|
||
# If you have the whole GHS POP raster, set the path after importing like so: | ||
# >>> sb.config.Config.FULL_RASTER = ... | ||
partitioner.save() |