Skip to content

Python API

get_network_line_endpoints(dataset_path, output_features, edge_type=3)

Retrieve the endpoints of network lines from the specified network dataset.

Parameters:

Name Type Description Default
dataset_path Union[str, Path]

Path to the network dataset.

required
output_features Union[str, Path]

Path to the output feature class.

required
edge_type int

Type of network lines to retrieve. Default is 3 (highway ramps).

3

Returns:

Name Type Description
Path Path

The endpoints feature class.

Source code in src/get_highway_features/__main__.py
def get_network_line_endpoints(
    dataset_path: Union[str, Path],
    output_features: Union[str, Path],
    edge_type: Optional[int] = 3,
) -> Path:
    """
    Retrieve the endpoints of network lines from the specified network dataset.

    Args:
        dataset_path (Union[str, Path]): Path to the network dataset.
        output_features (Union[str, Path]): Path to the output feature class.
        edge_type (int): Type of network lines to retrieve. Default is 3 (highway ramps).

    Returns:
        Path: The endpoints feature class.
    """
    # get the network lines layer
    lines = get_network_lines_layer(dataset_path, edge_type=edge_type)

    # create the feature layer for the endpoints
    endpoints_features = arcpy.management.FeatureVerticesToPoints(
        in_features=lines,
        out_feature_class=output_features,
        point_location="BOTH_ENDS",
    )[0]

    logger.debug("Retrieved endpoints of network lines.")

    return Path(endpoints_features)

get_network_lines_midpoints(dataset_path, output_features, edge_type=3)

Retrieve the midpoints of network lines from the specified network dataset.

Parameters:

Name Type Description Default
dataset_path Union[str, Path]

Path to the network dataset.

required
output_features Union[str, Path]

Path to the output feature class.

required
edge_type int

Type of network lines to retrieve. Default is 3 (highway ramps).

3
Source code in src/get_highway_features/__main__.py
def get_network_lines_midpoints(
    dataset_path: Union[str, Path],
    output_features: Union[str, Path],
    edge_type: Optional[int] = 3) -> Path:
    """
    Retrieve the midpoints of network lines from the specified network dataset.

    Args:
        dataset_path (Union[str, Path]): Path to the network dataset.
        output_features (Union[str, Path]): Path to the output feature class.
        edge_type (int): Type of network lines to retrieve. Default is 3 (highway ramps).
    """
    # get the network lines layer
    lines = get_network_lines_feature_set(dataset_path, edge_type=edge_type)

    # create the feature layer for the midpoints
    midpoints_features = arcpy.management.FeatureVerticesToPoints(
        in_features=lines,
        out_feature_class=output_features,
        point_location="MID",
    )[0]

    logger.debug("Retrieved midpoints of network lines.")

    return Path(midpoints_features)