From 2cf5f4d4191b8c9b4a15395e07dd47b3e8507c7c Mon Sep 17 00:00:00 2001 From: Michael Szell Date: Thu, 18 Apr 2024 18:19:09 +0200 Subject: [PATCH] Polish mwe.py and make it more user-friendly --- scripts/examples/mwe.py | 45 +++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/scripts/examples/mwe.py b/scripts/examples/mwe.py index 0a05da9..b4d2533 100644 --- a/scripts/examples/mwe.py +++ b/scripts/examples/mwe.py @@ -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()