benchmark-urbanism / cityseer-api Goto Github PK
View Code? Open in Web Editor NEWComputational tools for urban analysis
Home Page: https://cityseer.benchmarkurbanism.com
License: GNU Affero General Public License v3.0
Computational tools for urban analysis
Home Page: https://cityseer.benchmarkurbanism.com
License: GNU Affero General Public License v3.0
Display the geometries for segments when plotting.
Requires a bit more thought about whether to further formalise and refine the plotting options...
The crawl procedure has been removed from the graph consolidation method and replaced with a by_neighbours
strategy. This strategy better preserves topology.
A subsequent improvement would be to split parallel geometries where nodes are out of lock-step. This may remove the need for decomposition steps prior to final consolidation, which might result in cleaner and quicker consolidation.
Progress bars are currently difficult with parallel execution in numba
.
See krishnanlab/PecanPy#5 / numba/numba#4267
Forthcoming enhancements to numba
may add configurable chunk-sizes for prange
which may therefore allow for a more polished parallel mode progress bar, ideally with callback to objmode
for invocation of something like tqdm
.
See numba/numba#6025
For now, non-sequential progress bar updates and CPU watching will have to do!
Zero-length node maps are caught and reported by the checks
module, though it may be good to flag this at an earlier stage of graph creation.
Describe the bug
When using a network that has coordinate values below 0, like in case of EPSG 5514, node_centrality
raises an error as you have a check there for this case.
To Reproduce
Steps to reproduce the behavior:
import geopandas
import momepy
import networkx as nx
from cityseer.tools import graphs
from cityseer.metrics import networks
df = geopandas.read_file(momepy.datasets.get_path("bubenec"), layer="streets").to_crs(5514)
# get compatible graph
G = momepy.gdf_to_nx(df)
nx.set_node_attributes(G, {n: {"x":n[0], "y":n[1]} for n in G.nodes})
nx.set_edge_attributes(G, {(i, v, k): {"geom":a["geometry"]} for i, v, k, a in G.edges(data=True, keys=True)})
nodes_gdf, network_structure = graphs.network_structure_from_nx(G, crs=df.crs)
nodes_gdf = networks.node_centrality(
measures=["node_harmonic", "node_betweenness"],
network_structure=network_structure,
nodes_gdf=nodes_gdf,
distances=[400],
)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/martin/Git/momepy/Untitled-1.ipynb Cell 10 in <cell line: 1>()
----> 1 nodes_gdf = networks.node_centrality(
2 measures=["node_harmonic", "node_betweenness"],
3 network_structure=network_structure,
4 nodes_gdf=nodes_gdf,
5 distances=[400],
6 )
File ~/mambaforge/envs/geo_dev/lib/python3.10/site-packages/cityseer/metrics/networks.py:499, in node_centrality(measures, network_structure, nodes_gdf, distances, betas, jitter_scale, angular, min_threshold_wt)
423 def node_centrality(
424 measures: Union[list[str], tuple[str]],
425 network_structure: structures.NetworkStructure,
(...)
431 min_threshold_wt: float = MIN_THRESH_WT,
432 ) -> gpd.GeoDataFrame:
433 r"""
434 Compute node-based network centrality.
435
(...)
497
498 """
--> 499 network_structure.validate()
500 _distances, _betas = pair_distances_betas(distances, betas, min_threshold_wt)
501 # see centrality.local_centrality for integrity checks on closeness and betweenness keys
502 # typos are caught below
File ~/mambaforge/envs/geo_dev/lib/python3.10/site-packages/numba/experimental/jitclass/boxing.py:61, in _generate_method.<locals>.wrapper(*args, **kwargs)
59 @wraps(func)
60 def wrapper(*args, **kwargs):
---> 61 return method(*args, **kwargs)
File ~/mambaforge/envs/geo_dev/lib/python3.10/site-packages/cityseer/structures.py:92, in validate()
90 raise ValueError("X, Y and 'live' arrays are not the same length")
91 if not np.all(np.isfinite(self.xs)) or not np.all(self.xs >= 0):
---> 92 raise ValueError("Missing or invalid start x data encountered.")
93 if not np.all(np.isfinite(self.ys)) or not np.all(self.ys >= 0):
94 raise ValueError("Missing or invalid start y data encountered.")
ValueError: Missing or invalid start x data encountered.
Expected behavior
The computation should normally work, this will not be the only use case where negative projected coordinates appear.
Hi,
When I try to import io using
from cityseer.tools import graphs, io
I am getting
TypeError: 'numpy._DTypeMeta' object is not subscriptable
Output from spyder call 'get_namespace_view':
/Users/mohammadalattar/opt/anaconda3/lib/python3.9/site-packages/spyder_kernels/utils/nsview.py:443: UserWarning: legacy printing option can currently only be '1.13', '1.21', or `False`
np.set_printoptions(**np_printoptions
Betweenness assigns a node to the (first) path on the shortest route.
Therefore, the node will be assigned to the first out of multiple equidistant routes from A to B.
When working with shortest or simplest paths, it is highly unlikely for exactly equal paths to exist; nevertheless, it would be nice to figure out a method for dispersing node assignments for routes that are approximately equal to each other. e.g. Manhattan-like grids where numerous approximately equal routes exist from A to B.
A drawback to the above is that this may substantially complicate the underlying shortest path algorithm because multiple predecessors have to be tracked if they are within some or another tolerance of each other...
A tempting strategy may be to modify the usual shortest path algorithm where updates to the routes in the shortest-path tree are randomly executed if within a small tolerance of the existing shortest path to the same node in the tree. e.g. assuming a 2% tolerance, then a newly found route of 98m would randomly override / not override an existing shortest-route of 100m. The problem with this approach is that all subsequent calculations for shortest / between paths will follow this same route... i.e. it is the same problem as before, just that the route isn't necessarily the first option.
Consider adding a heatmap plot function.
This is useful for large graphs.
It is worth comparing performance if switching from a simple pythagorean spatial filter to the shapely
rtree
filter.
Hi,
I've noticed that cityseer pins requires-python = ">=3.10, <3.12"
. What is blocking support of Python 3.12?
Edit: The reason I am asking is that pip install cityseer
tries to pull 1.2.1 because that seems to be the last one without that pin. And that version is broken due to #39. Even if it wasn't, it is quite out of date :).
Return column with zeros instead of nothing if landuse / stats label does not exist.
Remove unnecessary smaller distance thresholds for distance to landuse measures
Describe the bug
when running the shortest path node centrality the progress does not update. Running on VS code on windows 10
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.
I'm wondering about adding a conversion function for a momepy
street network GeoDataFrame
to cityseer
compatible networkx
MultiGraph
.
Here is an initial sketch of what this might look like: momepy_to_cityseer
This would mainly be intended for people who want to:
networkX
(e.g. shortest path sidestepping issue)momepy
) using the street network as a backboneI'm curious what your thoughts are on things to take into account so that this is useful, e.g.
momepy
GeoDataFrame
to cityseer
then back to momepy
? If so, the edge ids would need to be chained through. The drawback to a round-trip is that network cleaning or decomposition can't be done without losing the association.GeoDataFrame
or would there be cases where it is better to go from a momepy
formatted networkx
Graph
?There are probably other things but that's all that comes to mind for now...
Is your feature request related to a problem? Please describe.
Add type checking for statistical data aggregation - e.g. catch None
and other invalid (per numpy
/ numba
) data types
Numba is introducing support for functions as first-class types. This means that the workflows in the core centrality and landuse methods can be parcelled into functions which can then be placed in a list depending on selected options.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.