edisgo.tools.geo
Functions
|
Transforms to equidistant projection (epsg:3035). |
|
Transforms back from equidistant projection to given projection. |
|
Transforms from specified projection to other specified projection. |
|
Determines lines that are at least partly within buffer around given bus. |
|
Calculates the geodesic distance between two buses in km. |
|
Finds the nearest bus in bus_target to a given point. |
|
Searches all lines for the nearest possible connection object per line. |
|
Returns the medium-voltage grid district as a GeoDataFrame. |
Module Contents
- edisgo.tools.geo.proj2equidistant(srid)
Transforms to equidistant projection (epsg:3035).
- Parameters:
srid (int) – Spatial reference identifier of geometry to transform.
- Return type:
- edisgo.tools.geo.proj2equidistant_reverse(srid)
Transforms back from equidistant projection to given projection.
- Parameters:
srid (int) – Spatial reference identifier of geometry to transform.
- Return type:
- edisgo.tools.geo.proj_by_srids(srid1, srid2)
Transforms from specified projection to other specified projection.
- Parameters:
- Return type:
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)
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:
- edisgo.tools.geo.calc_geo_dist_vincenty(grid_topology, bus_source, bus_target, branch_detour_factor=1.3)
Calculates the geodesic distance between two buses in km.
The detour factor in config_grid is incorporated in the geodesic distance.
- Parameters:
- Returns:
Distance in km.
- Return type:
- edisgo.tools.geo.find_nearest_bus(point, bus_target)
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:
Notes
For performance the nearest bus is selected with a vectorised equirectangular distance approximation rather than computing an exact geopy geodesic to every candidate (which is O(parks x buses) of iterative Karney calls and dominates runtime on large grids). The exact geodesic is still evaluated for the selected bus, so the returned distance is always exact. The selection may differ from an exact nearest-neighbour search only in rare near-tie cases (~0.1 % at grid-district scale), where the chosen bus is then practically equidistant – the resulting connection line is at most a few metres (< 0.3 %) longer. This is well below the geographic accuracy of the bus coordinates and is accepted in exchange for the large runtime gain.
- edisgo.tools.geo.find_nearest_conn_objects(grid_topology, bus, lines, conn_diff_tolerance=0.0001)
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: