from cityseer.tools import io, plotOSM network from a buffered coordinate
Use a buffered point to create a networkx graph from OSM.
Use this approach when you have a centre-point, such as a longitude and latitude, and you wish to create a network within a certain radius distance.
Define a longitude and latitude, and a buffer distance in meters.
lng, lat = -0.13396079424572427, 51.51371088849723
buffer = 500A geometry can now be created using the buffered_point_poly function available from the cityseer package’s io module.
poly_wgs, epsg_code = io.buffered_point_poly(lng, lat, buffer)
print(epsg_code)
poly_wgs4326
You can then use this geometry to specify the boundaries to be used for creating a network using the osm_graph_from_poly function.
G = io.osm_graph_from_poly(poly_wgs, green_footways=False) # False by default
print(G)
plot.plot_nx(G, plot_geoms=True)INFO:cityseer.tools.graphs:Generating interpolated edge geometries.
100%|██████████| 3318/3318 [00:00<00:00, 54141.53it/s]
INFO:cityseer.tools.io:Converting networkX graph to CRS code 32630.
INFO:cityseer.tools.io:Processing node x, y coordinates.
100%|██████████| 3094/3094 [00:00<00:00, 689248.81it/s]
INFO:cityseer.tools.io:Processing edge geom coordinates, if present.
100%|██████████| 3318/3318 [00:00<00:00, 22012.71it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 3094/3094 [00:00<00:00, 24259.26it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 1826/1826 [00:00<00:00, 1133461.46it/s]
100%|██████████| 1826/1826 [00:00<00:00, 19660.38it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 1602/1602 [00:00<00:00, 71124.51it/s]
100%|██████████| 1208/1208 [00:00<00:00, 274173.12it/s]
INFO:cityseer.tools.graphs:Removing dangling nodes.
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 1427/1427 [00:00<00:00, 1143536.84it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 1143/1143 [00:00<00:00, 1165027.82it/s]
INFO:cityseer.tools.graphs:Splitting opposing edges.
100%|██████████| 940/940 [00:00<00:00, 295506.35it/s]
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1143/1143 [00:00<00:00, 190362.51it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 1141/1141 [00:00<00:00, 1147925.37it/s]
INFO:cityseer.tools.graphs:Splitting opposing edges.
100%|██████████| 940/940 [00:00<00:00, 39842.41it/s]
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1147/1147 [00:00<00:00, 397888.24it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 1147/1147 [00:00<00:00, 1133568.97it/s]
INFO:cityseer.tools.graphs:Splitting opposing edges.
100%|██████████| 940/940 [00:00<00:00, 197428.43it/s]
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1147/1147 [00:00<00:00, 433958.75it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 1147/1147 [00:00<00:00, 1414128.95it/s]
INFO:cityseer.tools.graphs:Splitting opposing edges.
100%|██████████| 940/940 [00:00<00:00, 66771.31it/s]
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1147/1147 [00:00<00:00, 364929.58it/s]
INFO:cityseer.tools.util:Creating nodes STR tree
100%|██████████| 940/940 [00:00<00:00, 51693.95it/s]
INFO:cityseer.tools.graphs:Consolidating nodes.
100%|██████████| 940/940 [00:00<00:00, 283541.59it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1147/1147 [00:00<00:00, 478693.20it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 940/940 [00:00<00:00, 820188.43it/s]
INFO:cityseer.tools.util:Creating nodes STR tree
100%|██████████| 937/937 [00:00<00:00, 74495.09it/s]
INFO:cityseer.tools.graphs:Consolidating nodes.
100%|██████████| 937/937 [00:00<00:00, 6607.85it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1063/1063 [00:00<00:00, 13900.20it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 874/874 [00:00<00:00, 609953.69it/s]
INFO:cityseer.tools.util:Creating nodes STR tree
100%|██████████| 869/869 [00:00<00:00, 100814.58it/s]
INFO:cityseer.tools.graphs:Consolidating nodes.
100%|██████████| 869/869 [00:00<00:00, 95854.05it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1041/1041 [00:00<00:00, 216645.35it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 869/869 [00:00<00:00, 809247.37it/s]
INFO:cityseer.tools.util:Creating nodes STR tree
100%|██████████| 868/868 [00:00<00:00, 93335.79it/s]
INFO:cityseer.tools.graphs:Consolidating nodes.
100%|██████████| 868/868 [00:00<00:00, 18575.25it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1023/1023 [00:00<00:00, 238336.55it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 856/856 [00:00<00:00, 948817.18it/s]
INFO:cityseer.tools.util:Creating nodes STR tree
100%|██████████| 855/855 [00:00<00:00, 105078.82it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 1020/1020 [00:00<00:00, 1108626.61it/s]
INFO:cityseer.tools.graphs:Snapping gapped endings.
100%|██████████| 855/855 [00:00<00:00, 22494.57it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 1075/1075 [00:00<00:00, 1345130.31it/s]
INFO:cityseer.tools.graphs:Splitting opposing edges.
100%|██████████| 855/855 [00:00<00:00, 22278.39it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 1227/1227 [00:00<00:00, 363216.25it/s]
INFO:cityseer.tools.graphs:Removing dangling nodes.
100%|██████████| 942/942 [00:00<00:00, 477178.06it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 788/788 [00:00<00:00, 25509.10it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 833/833 [00:00<00:00, 865029.77it/s]
INFO:cityseer.tools.graphs:Splitting opposing edges.
100%|██████████| 548/548 [00:00<00:00, 17928.29it/s]
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 839/839 [00:00<00:00, 211390.70it/s]
INFO:cityseer.tools.util:Creating nodes STR tree
100%|██████████| 548/548 [00:00<00:00, 158057.94it/s]
INFO:cityseer.tools.graphs:Consolidating nodes.
100%|██████████| 548/548 [00:00<00:00, 1559.20it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 651/651 [00:00<00:00, 48358.10it/s]
INFO:cityseer.tools.util:Creating edges STR tree.
100%|██████████| 607/607 [00:00<00:00, 1405045.55it/s]
INFO:cityseer.tools.graphs:Splitting opposing edges.
100%|██████████| 415/415 [00:00<00:00, 21333.68it/s]
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 607/607 [00:00<00:00, 202010.83it/s]
INFO:cityseer.tools.util:Creating nodes STR tree
100%|██████████| 415/415 [00:00<00:00, 84484.60it/s]
INFO:cityseer.tools.graphs:Consolidating nodes.
100%|██████████| 415/415 [00:00<00:00, 2576.70it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
100%|██████████| 519/519 [00:00<00:00, 87995.95it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 337/337 [00:00<00:00, 160714.09it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 50.
100%|██████████| 494/494 [00:00<00:00, 96560.08it/s]
INFO:cityseer.tools.graphs:Ironing edges.
100%|██████████| 491/491 [00:00<00:00, 24911.43it/s]
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 1.
100%|██████████| 490/490 [00:00<00:00, 340491.88it/s]
INFO:cityseer.tools.graphs:Removing dangling nodes.
100%|██████████| 323/323 [00:00<00:00, 307900.04it/s]
INFO:cityseer.tools.graphs:Removing filler nodes.
100%|██████████| 320/320 [00:00<00:00, 232936.01it/s]
INFO:cityseer.tools.plot:Preparing graph nodes
INFO:cityseer.tools.plot:Preparing graph edges
MultiGraph with 313 nodes and 481 edges
100%|██████████| 481/481 [00:00<00:00, 38625.72it/s]

Set the projected parameter to True if you would rather use the local UTM projection for the boundary.
poly_utm, epsg_code = io.buffered_point_poly(lng, lat, buffer, projected=True)
print(epsg_code)
poly_utm32630
In this case, remember to set the poly_crs parameter to the appropriate UTM CRS if using the resultant geometry as a parameter for the osm_graph_from_poly function.
G_utm = io.osm_graph_from_poly(poly_utm, poly_crs_code=epsg_code)
print(G_utm)
plot.plot_nx(G_utm, plot_geoms=True)INFO:cityseer.tools.graphs:Generating interpolated edge geometries.
INFO:cityseer.tools.io:Converting networkX graph to CRS code 32630.
INFO:cityseer.tools.io:Processing node x, y coordinates.
INFO:cityseer.tools.io:Processing edge geom coordinates, if present.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.graphs:Removing dangling nodes.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Splitting opposing edges.
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Splitting opposing edges.
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Splitting opposing edges.
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Splitting opposing edges.
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.util:Creating nodes STR tree
INFO:cityseer.tools.graphs:Consolidating nodes.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.util:Creating nodes STR tree
INFO:cityseer.tools.graphs:Consolidating nodes.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.util:Creating nodes STR tree
INFO:cityseer.tools.graphs:Consolidating nodes.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.util:Creating nodes STR tree
INFO:cityseer.tools.graphs:Consolidating nodes.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.util:Creating nodes STR tree
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Snapping gapped endings.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Splitting opposing edges.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.graphs:Removing dangling nodes.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Splitting opposing edges.
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.util:Creating nodes STR tree
INFO:cityseer.tools.graphs:Consolidating nodes.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.util:Creating edges STR tree.
INFO:cityseer.tools.graphs:Splitting opposing edges.
INFO:cityseer.tools.graphs:Squashing opposing nodes
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.util:Creating nodes STR tree
INFO:cityseer.tools.graphs:Consolidating nodes.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 25.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 50.
INFO:cityseer.tools.graphs:Ironing edges.
INFO:cityseer.tools.graphs:Merging parallel edges within buffer of 1.
INFO:cityseer.tools.graphs:Removing dangling nodes.
INFO:cityseer.tools.graphs:Removing filler nodes.
INFO:cityseer.tools.plot:Preparing graph nodes
INFO:cityseer.tools.plot:Preparing graph edges
MultiGraph with 320 nodes and 487 edges
