cityseer.structures

The structures module defines data structures used by the lower-level cityseer API.

The data structures defined in this modules are created and managed automatically by the user-facing API. It is therefore not necessary to create these structures directly unless interaction the lower-level API is intentional.

NodeMap

NodeMap structure representing the x, y, and live information for the network.

Each attribute contains a numpy array with indices corresponding to the graph’s node indices.

It is not necessary to invoke this class directly if using a NetworkStructure class, which will generate the NodeMap implicitly.

Properties

xs
ndarray
ys
ndarray
live
ndarray
count

Methods

NodeMap.__init__

NodeMap(
nodes_n)

Instance a NodeMap.

Parameters

nodes_n
int

The number of nodes to be contained by this NodeMap instance.

NodeMap.x_y

x_y(
node_idx)

Return the x and y coordinates for a given node index.

Parameters

node_idx
int

The node index for which to return x and y coordinates.

Returns

x
float

x coordinate.

y
float

y coordinate.

NodeMap.validate

validate()

Validate this NodeMap instance.

EdgeMap

EdgeMap structure containing edge (segment) information for the network.

Each attribute contains a numpy array with indices corresponding to the graph’s edges.

It is not necessary to invoke this class directly if using a NetworkStructure class, which will generate the EdgeMap implicitly.

Properties

start
ndarray
end
ndarray
length
ndarray
angle_sum
ndarray
imp_factor
ndarray
in_bearing
ndarray
out_bearing
ndarray
count

Methods

EdgeMap.__init__

EdgeMap(
edges_n)

Create an EdgeMap instance.

Parameters

edges_n
int

The number of edges to be contained by this EdgeMap instance.

EdgeMap.validate

validate()

Validate this Edgemap instance.

NetworkStructure

NetworkStructure instance consisting of nodes, edges and node_edge_map attributes.

Each of these attributes will be created automatically when instancing this class.

Properties

nodes
NodeMap
edges
EdgeMap
node_edge_map
dict

Methods

NetworkStructure.__init__

NetworkStructure(
nodes_n,
edges_n)

Instances a NetworkStructure.

Parameters

nodes_n
int

The number of nodes this NetworkStructure will contain.

edges_n
int

The number of edges this NetworkStructure will contain.

NetworkStructure.set_node

set_node(
node_idx,
node_x,
node_y,
node_live=True)

Add a node to the NetworkStructure.

Parameters

node_idx
int

The index at which to add the node.

node_x
float

The x coordinate for the added node.

node_y
float

The y coordinate for the added node.

node_live
bool

The live node attribute identifies nodes falling within the areal boundary of interest as opposed to those that fall within the surrounding buffered area. See the edge-rolloff section in the guide.

NetworkStructure.set_edge

set_edge(
start_node_idx,
end_node_idx,
length,
angle_sum,
imp_factor,
in_bearing,
out_bearing)

Add an edge to the NetworkStructure. Edges are directed, meaning that each bidirectionaly street is represented twice: once in each direction; start/end nodes and in/out bearings will differ accordingly.

Parameters

start_node_idx
int

Index for the starting node for the added edge.

end_node_idx
int

Index for the ending node for the added edge.

length
float

The length edge attribute should always correspond to the edge lengths in metres. This is used when calculating the distances traversed by the shortest-path algorithm so that the respective dmaxd_{max} maximum distance thresholds can be enforced: these distance thresholds are based on the actual network-paths traversed by the algorithm as opposed to crow-flies distances.

angle_sum
float

The angle_sum edge bearing should correspond to the total angular change along the length of the segment. This is used when calculating angular impedances for simplest-path measures. The in_bearing and out_bearing attributes respectively represent the starting and ending bearing of the segment. This is also used when calculating simplest-path measures when the algorithm steps from one edge to another.

imp_factor
float

The imp_factor edge attribute represents an impedance multiplier for increasing or diminishing the impedance of an edge. This is ordinarily set to 1, therefor not impacting calculations. By setting this to greater or less than 1, the edge will have a correspondingly higher or lower impedance. This can be used to take considerations such as street gradients into account, but should be used with caution.

in_bearing
float

The edge’s inwards angular bearing.

out_bearing
float

The edge’s outwards angular bearing.

NetworkStructure.validate

validate()

Validate Network Structure.

DataMap

NodeMap instance representing the x, y data coordinates and the nearest adjacent network node indices.

Each attribute contains a numpy array with indices corresponding to the graph’s node indices.

Properties

xs
ndarray
ys
ndarray
nearest_assign
ndarray
next_nearest_assign
ndarray
data_id
ndarray
count

Methods

DataMap.__init__

DataMap(
data_n)

Instance a DataMap.

Parameters

data_n
int

The number of data points to be contained by this DataMap instance.

DataMap.set_data_point

set_data_point(
data_idx,
data_x,
data_y,
data_id)

Add a data point.

Parameters

data_idx
int

The index for the added node.

data_x
np.float32

The x coordinate for the added node.

data_y
np.float32

The y coordinate for the added node.

data_id
np.int_ | None

An optional key for each datapoint. Used for deduplication.

DataMap.x_y

x_y(
data_idx)

Return the x and y coordinates for a given data point index.

Parameters

data_idx
int

The data point index for which to return x and y coordinates.

Returns

x
float

x coordinate.

y
float

y coordinate.

DataMap.validate

validate(
check_assigned=False)

Validate this DataMap instance.

Parameters

check_assigned
bool

Whether to check if data points have been assigned to a network.