edisgo.tools.geo

Module Contents

Functions

proj2equidistant(srid)

Transforms to equidistant projection (epsg:3035).

proj2equidistant_reverse(srid)

Transforms back from equidistant projection to given projection.

proj_by_srids(srid1, srid2)

Transforms from specified projection to other specified projection.

calc_geo_lines_in_buffer(grid_topology, bus, grid[, ...])

Determines lines that are at least partly within buffer around given bus.

calc_geo_dist_vincenty(grid_topology, bus_source, ...)

Calculates the geodesic distance between two buses in km.

find_nearest_bus(point, bus_target)

Finds the nearest bus in bus_target to a given point.

find_nearest_conn_objects(grid_topology, bus, lines[, ...])

Searches all lines for the nearest possible connection object per line.

mv_grid_gdf(edisgo_obj)

edisgo.tools.geo.proj2equidistant(srid)[source]

Transforms to equidistant projection (epsg:3035).

Parameters:

srid (int) – Spatial reference identifier of geometry to transform.

Return type:

functools.partial()

edisgo.tools.geo.proj2equidistant_reverse(srid)[source]

Transforms back from equidistant projection to given projection.

Parameters:

srid (int) – Spatial reference identifier of geometry to transform.

Return type:

functools.partial()

edisgo.tools.geo.proj_by_srids(srid1, srid2)[source]

Transforms from specified projection to other specified projection.

Parameters:
  • srid1 (int) – Spatial reference identifier of geometry to transform.

  • srid2 (int) – Spatial reference identifier of destination CRS.

Return type:

functools.partial()

Notes

Projections often used are conformal projection (epsg:4326), equidistant projection (epsg:3035) and spherical mercator projection (epsg:3857).

edisgo.tools.geo.calc_geo_lines_in_buffer(grid_topology, bus, grid, buffer_radius=2000, buffer_radius_inc=1000)[source]

Determines lines that are at least partly within buffer around given bus.

If there are no lines, the buffer specified in buffer_radius is successively extended by buffer_radius_inc until lines are found.

Parameters:
  • grid_topology (Topology) –

  • bus (pandas.Series) – Data of origin bus the buffer is created around. Series has same rows as columns of buses_df.

  • grid (Grid) – Grid whose lines are searched.

  • buffer_radius (float, optional) – Radius in m used to find connection targets. Default: 2000.

  • buffer_radius_inc (float, optional) – Radius in m which is incrementally added to buffer_radius as long as no target is found. Default: 1000.

Returns:

List of lines in buffer (meaning close to the bus) sorted by the lines’ representatives.

Return type:

list(str)

edisgo.tools.geo.calc_geo_dist_vincenty(grid_topology, bus_source, bus_target, branch_detour_factor=1.3)[source]

Calculates the geodesic distance between two buses in km.

The detour factor in config_grid is incorporated in the geodesic distance.

Parameters:
  • grid_topology (Topology) –

  • bus_source (str) – Name of source bus as in index of buses_df.

  • bus_target (str) – Name of target bus as in index of buses_df.

  • branch_detour_factor (float) – Detour factor to consider that two buses can usually not be connected directly. Default: 1.3.

Returns:

Distance in km.

Return type:

float

edisgo.tools.geo.find_nearest_bus(point, bus_target)[source]

Finds the nearest bus in bus_target to a given point.

Parameters:
  • point (shapely.Point) – Point to find the nearest bus for.

  • bus_target (pandas.DataFrame) – Dataframe with candidate buses and their positions given in ‘x’ and ‘y’ columns. The dataframe has the same format as buses_df.

Returns:

Tuple that contains the name of the nearest bus and its distance in km.

Return type:

tuple(str, float)

edisgo.tools.geo.find_nearest_conn_objects(grid_topology, bus, lines, conn_diff_tolerance=0.0001)[source]

Searches all lines for the nearest possible connection object per line.

It picks out 1 object out of 3 possible objects: 2 line-adjacent buses and 1 potentially created branch tee on the line (using perpendicular projection). The resulting stack (list) is sorted ascending by distance from bus.

Parameters:
  • grid_topology (Topology) –

  • bus (pandas.Series) – Data of bus to connect. Series has same rows as columns of buses_df.

  • lines (list(str)) – List of line representatives from index of lines_df.

  • conn_diff_tolerance (float, optional) – Threshold which is used to determine if 2 objects are at the same position. Default: 0.0001.

Returns:

List of connection objects. Each object is represented by dict with representative, shapely object and distance to node.

Return type:

list(dict)

edisgo.tools.geo.mv_grid_gdf(edisgo_obj: edisgo.EDisGo)[source]