generalization.n100.road package
Submodules
generalization.n100.road.dam module
- generalization.n100.road.dam.main()[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.n100.road.dam.data_check()[source]
sjekker om det er noen veier innen 60 meter av demninger
- generalization.n100.road.dam.restore_deleted_lines(layer, backup)[source]
Gjennopretter features som har blitt slettet under snapping
- generalization.n100.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.n100.road.dam.get_endpoints_cords(polyline)[source]
Return a list of Point objects for the start/end of every part.
- generalization.n100.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.n100.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.n100.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.n100.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.n100.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.n100.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.n100.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.n100.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.n100.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.n100.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.n100.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.n100.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.n100.road.dam.snap_and_merge_pre()[source]
snapper og kombinerer veier som har blitt flyttet og veier som ikke har blitt flyttet
- generalization.n100.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.n100.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.n100.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