generalization.n250.road package

Submodules

generalization.n250.road.dam module

generalization.n250.road.dam.generalize_dam()[source]
Hva den gjør:

Denne tar veier som går innen 60 meter av demninger og flytter de ut til 60 meter unna demningen.

Hvorfor:

For at symbologien skal være synlig i N100 kartet.

generalization.n250.road.dam.data_check()[source]

sjekker om det er noen veier innen 60 meter av demninger

generalization.n250.road.dam.build_backup(layer)[source]

Bygger en backup dict av en layer

generalization.n250.road.dam.restore_deleted_lines(layer, backup)[source]

Gjennopretter features som har blitt slettet under snapping

generalization.n250.road.dam.merge_all_lines2(fc, tolerance=5.0)[source]

Merges all lines in a feature class that share endpoints and have the same objtype and vegkategori.

generalization.n250.road.dam.within_tol(pt1, pt2, tol)[source]

Euclidean distance test.

generalization.n250.road.dam.get_endpoints_cords(polyline)[source]

Return a list of Point objects for the start/end of every part.

generalization.n250.road.dam.snap_by_objtype(layer)[source]

Snapper veier med samme objtype

generalization.n250.road.dam.move_line_away(geom, near_x, near_y, distance)[source]

Move a polyline geometry away from a point (near_x, near_y) by a specified distance.

generalization.n250.road.dam.get_endpoints(polyline: arcpy.Geometry) tuple[arcpy.PointGeometry, arcpy.PointGeometry][source]

Returns the start and end points of a polyline

Parameters:

polyline (arcpy.Geometry) – The geometry (line) to be analysed

Returns:

tuple with start and end points

Return type:

tuple(arcpy.PointGeometry)

generalization.n250.road.dam.add_road(road_lyr: str, roads: dict[list], tolerance: float = 2.0) dict[list][source]

Adds roads selected in road_lyr to the dictionary roads if they are connected (closer than tolerance). These are the roads relevant for the movement analysis.

Parameters:
  • road_lyr (str) – String to the feature layer

  • roads (dict[list]) – Dictionary with relevant road objects

  • tolerance (float) – Float number showing tolerance of connection to be added, default 2.0

Returns:

Updated dictionary with relevant road objects

Return type:

roads (dict[list])

generalization.n250.road.dam.find_merge_candidate(short_geom: arcpy.Geometry, all_roads: list[list], buffer: arcpy.Geometry, tolerance: float = 2.0) str | None[source]

Finds a road geometry that shares a common end point

Parameters:
  • short_geom (arcpy.Geometry) – The geometry that should be checked

  • all_roads (list[list]) – oid and geom of relevant roads to connect to

  • buffer (arcpy.Geometry) – The geometry of the relevant buffer

  • tolerance (float) – Float number showing tolerance of connection to be added, default 2.0

Returns:

The oid of the matched road oid if one, else None

Return type:

str | None

generalization.n250.road.dam.reverse_geometry(polyline: arcpy.Geometry) arcpy.Polyline[source]

Createas a reversed copy of the input geometry (line). Only singlepart.

Parameters:

polyline (arcpy.Geometry) – The line to be reversed

Returns:

The reversed line

Return type:

arcpy.Polyline

generalization.n250.road.dam.merge_lines(line1: arcpy.Geometry, line2: arcpy.Geometry, tolerance: float = 2.0) arcpy.Polyline[source]

Merges two lines into one common one. Calls itself with reversed geometries if incorrect directions of the input geometries.

Parameters:
  • line1 (arcpy.Geometry) – The first line to merge

  • line2 (arcpy.Geometry) – The second line to merge

  • tolerance (float) – Float number showing tolerance of connection to be merged, default 2.0

Returns:

A merged polyline containing both the geometries. None if something fails

Return type:

arcpy.Polyline | None

generalization.n250.road.dam.create_single_buffer_line(buffer: arcpy.Geometry, water) None[source]

Creates a polyline showing the edges of a buffer, excluding areas in water, and saves it to a temporarly ‘in_memory’-layer.

Parameters:
  • buffer (arcpy.Geometry) – The buffer to create the line from

  • water – The feature layer containing the water geometries

generalization.n250.road.dam.cluster_points(points: list[tuple], tolerance: float = 1.0) list[list][source]

Clusters points that are within the tolerance distance of each other.

Parameters:
  • points (list[tuple]) – A list of tuples containing all the points to be clustered

  • tolerance (float) – Float number showing tolerance of connection to be clustered, default 2.0

Returns:

A list of list where the internal lists are each cluster with the relevant point information

Return type:

list[list]

generalization.n250.road.dam.calculate_angle(p1: arcpy.Geometry, p2: arcpy.Geometry, p3: arcpy.Geometry) float[source]

Calculates the angle in point 2 between point 1 and 3.

Parameters:
  • p1 (arcpy.Geometry) – Point 1

  • p2 (arcpy.Geometry) – Point 2 (the angle to be calculated is in this point)

  • p3 (arcpy.Geometry) – Point 3

Returns:

The angle in point 2

Return type:

float

generalization.n250.road.dam.not_road_intersection(point: arcpy.Geometry, road_oid: str, roads: str) bool[source]

Checks if the point is connected to a road intersection or not.

Parameters:
  • point (arcpy.Geometry) – The point geometry to consider

  • road_oid (str) – The oid of the road containing this point

  • roads (str) – Feature layer containing all the relevant roads

Returns:

False if the point is in a road intersection, otherwise True

Return type:

bool

generalization.n250.road.dam.fetch_data()[source]
generalization.n250.road.dam.create_buffer()[source]
generalization.n250.road.dam.create_buffer_line()[source]
generalization.n250.road.dam.clip_and_erase_pre()[source]
Hva den gjør:

Seperer veier som er innen en mindre buffer rundt demningene og veier som er utenfor, i forbredelse på å flytte veiene. Hvis bru eller sti går over demningen blir det ikke inkludert i veier som skal flyttes

generalization.n250.road.dam.snap_merge_before_moving()[source]
Hva den gjør:

snapper og merger veier som er like før de blir flyttet

Hvorfor:

gjør det letter å beholde sammenhengen i veiene etter flytting

generalization.n250.road.dam.edit_geom_pre()[source]

Flytter veier inni buffer litt unna vannet

generalization.n250.road.dam.snap_and_merge_pre()[source]

snapper og kombinerer veier som har blitt flyttet og veier som ikke har blitt flyttet

generalization.n250.road.dam.connect_roads_with_buffers() dict[list][source]

Creates a dictionary where the keys are al the buffer oids, and the values are lists of lists containing the road geometry and information for all the roads connected to this buffer.

Returns:

A dictionary with key = buffer_oid, and values are

lists of the relevant information (oid, shape, …) of the related roads

Return type:

dict[list]

generalization.n250.road.dam.merge_instances(roads: dict[list]) defaultdict[list][source]

Merge the selected roads. For each road: select the relevant instances. For each type and category: merge the relevant instances.

Parameters:

roads (dict[list]) – Dictionary containing all the buffer -> road connections

Returns:

An updated dictionary with the merged geometry.

The list do contain the oid for every connected road

Return type:

defaultdict[list]

generalization.n250.road.dam.snap_roads(roads: dict[list]) None[source]

Snaps roads to the buffer edges. Points that are close to each other are snapped to the same point.

Parameters:

roads (dict[list]) – Dictionary containing the relationships between buffers and roads

generalization.n250.road.dam.remove_sharp_angles(roads: dict[list]) None[source]

Detects sharp edges in the polylines and deletes these points.

Parameters:

roads (dict[list]) – Dictionary containing the relationships between buffers and roads

generalization.n250.road.dam.delete_intermediate_files() None[source]

Deletes the intermediate files used during the process.

generalization.n250.road.data_preparation_2 module

generalization.n250.road.major_road_crossings module

generalization.n250.road.major_road_crossings.categories_major_road_crossings()[source]

Creates major road crossings feature classes and updates the attribute ‘er_kryssningspunkt’ in the input road feature class for all roads that cross major roads (E and R).

generalization.n250.road.major_road_crossings.select_intersect_and_copy(in_fc: str, select_fc: str, out_fc: str, lyr_name: str = 'tmp_lyr') None[source]

Creates a feature layer from ‘in_fc’, selects all features that intersect with ‘select_fc’, and copies the selected features to ‘out_fc’.

Parameters:
  • in_fc (str) – Input feature class to create a feature layer from

  • select_fc (str) – Feature class to select intersecting features from ‘in_fc’

  • out_fc (str) – Output feature class to store the selected features

  • lyr_name (str) – Name of the temporary feature layer. Default is “tmp_lyr”

generalization.n250.road.major_road_crossings.shrunked_underpass() None[source]

Creates shrunked buffers for roads with medium ‘U’ (underpass).

generalization.n250.road.major_road_crossings.shrunked_bridge() None[source]

Creates shrunked buffers for roads with medium ‘L’ (bridge).

generalization.n250.road.major_road_crossings.shrunked_ER_bridge() None[source]

Creates shrunked buffers for major roads with medium ‘L’ (bridge).

generalization.n250.road.major_road_crossings.surface_road() None[source]

Creates feature class for roads with medium ‘T’ (surface road).

generalization.n250.road.major_road_crossings.surface_ER() None[source]

Creates feature class for major roads with medium ‘T’ (surface road).

generalization.n250.road.major_road_crossings.cross() None[source]

Selects the crossings between shrunked underpass, shrunked bridge and surface roads with major roads (ER) and stores them in respective feature classes.

generalization.n250.road.major_road_crossings.keep() None[source]

Selects and keeps the most important crossings from the previously created crossing feature classes.

generalization.n250.road.major_road_crossings.update_crossing_point_attribute() None[source]

Creates a new field ‘er_kryssningspunkt’ in the input road feature class and updates it to 1 for all roads that intersect with the kept major road crossings.

generalization.n250.road.major_road_crossings.delete_intermediate_files() None[source]

Deletes the intermediate files used during the process.

generalization.n250.road.ramps_point module

generalization.n250.road.roundabouts module

generalization.n250.road.vegsperring module

generalization.n250.road.vegsperring.remove_roadblock()[source]

Identifies every road having some kind of roadblock 2 m from the centre line and marks them with either “ja” (yes) or “nei” (no).

Module contents