コード例 #1
0
def route_analysis_df(route_num, shapefile, rasterfile):
    """
       input the number of route, then output a GeoDataFrame with gradient and geometry
    information of that route, and elevation_gradient for each line segment. 
    Also will save the route as shapefile named 'route_shp'.
    
    Parameters
    ----------
    route_num: desired route number (integer)
    shapefile: route geospatial data (.shp file)
    rasterfile: elevation data file (.tif)
    
    Returns
    -------
    gdf_route: geodataframe with columns ['gradient', 'geometry']
    
    """
    route_shp = base.read_shape(shapefile, route_num)
    
    linestring_route_df = base.extract_point_df(route_shp)
    
    elevation, elevation_gradient, route_cum_distance, distance = base.gradient(route_shp, rasterfile)

    gdf_route = base.make_multi_lines( linestring_route_df, elevation_gradient) 
    
    return gdf_route
コード例 #2
0
def route_analysis_profile(route_num, shapefile, rasterfile):
    """
       input the number of route, then output elevation and road grade profiles.
    Also will save the route as shapefile named 'route_shp'.
    
    Parameters
    ----------
    route_num: desired route number (integer)
    shapefile: route geospatial data (.shp file)
    rasterfile: elevation data file (.tif)
    
    Returns
    -------
    route_plot: elevation and grade profiles for desired route
    """
    route_shp = base.read_shape(shapefile, route_num)
    
    linestring_route_df = base.extract_point_df(route_shp)
    
    elevation, elevation_gradient, route_cum_distance, distance = base.gradient(route_shp, rasterfile)

    gdf_route = base.make_multi_lines( linestring_route_df, elevation_gradient) 
    
    route_plot = base.profile_plot(elevation, elevation_gradient, route_cum_distance, route_num)
    
    return route_plot
コード例 #3
0
def route_analysis_map(route_num, shapefile, rasterfile):
    """
       input the number of route, then output an interactive map showing the route and road grade. 
    Also will save the route as shapefile named 'route_shp'.
    
    Parameters
    ----------
    route_num: desired route number (integer)
    shapefile: route geospatial data (.shp file)
    rasterfile: elevation data file (.tif)
    
    Returns
    -------
    map_display: interactive map for desired route
    """
    route_shp = base.read_shape(shapefile, route_num)
    
    linestring_route_df = base.extract_point_df(route_shp)
    
    elevation, elevation_gradient, route_cum_distance, distance = base.gradient(route_shp, rasterfile)

    gdf_route = base.make_multi_lines( linestring_route_df, elevation_gradient) 
    
    map_display = base.route_map(gdf_route)
    
    return map_display
コード例 #4
0
def route_analysis_all(route_num, shapefile, rasterfile):
    """
       input the number of route, then output an interactive map of the route, elevation and road grade profiles, and metrics calculated for the route. 
    Also will save the route as shapefile named 'route_shp'.
    
    Parameters
    ----------
    route_num: Desired route number (integer)
    shapefile: route geospatial data (.shp file)
    rasterfile: elevation data file (.tif)
    
    Returns
    -------
    map_display: interactive map for desired route
    route_plot: elevation and grade profiles for desired route
    display_metrics: results of metrics calculations
    """
    route_shp = base.read_shape(shapefile, route_num)
    
    linestring_route_df = base.extract_point_df(route_shp)
    
    elevation, elevation_gradient, route_cum_distance, distance = base.gradient(route_shp, rasterfile)

    gdf_route = base.make_multi_lines( linestring_route_df, elevation_gradient) 
    
    map_display = base.route_map(gdf_route)
    
    route_plot = base.profile_plot(elevation, elevation_gradient, route_cum_distance, route_num)
    
    display_metrics, _ = base.route_metrics(elevation, elevation_gradient, route_cum_distance, distance, route_num)
    
    return map_display, route_plot, display_metrics
コード例 #5
0
ファイル: test_base.py プロジェクト: aidowu/Route_Dynamics
def test_extract_point_df():
    """Test if the shape of dataframe is correct."""
    df45 = base.read_shape(shapefile, route_num)
    shape = base.extract_point_df(df45).shape
    assert shape == (208,
                     1), " Shape of df(route 45) coordinates should be (208,1)"
    return
コード例 #6
0
ファイル: test_base.py プロジェクト: aidowu/Route_Dynamics
def test_make_multi_lines():
    """Test if all gradient data are float64 type."""
    linestring_route_df = base.extract_point_df(route_shp)
    _, elevation_gradient, _, _ = base.gradient(route_shp, rasterfile)
    gdf_route = base.make_multi_lines(linestring_route_df, elevation_gradient)
    assert gdf_route[
        'gradient'].dtype == 'float64', 'Gradient columns should only contain number with float64 dtype.'
    return
コード例 #7
0
ファイル: test_base.py プロジェクト: aidowu/Route_Dynamics
def test_route_map():
    """Test if geodataframe contain null values."""
    linestring_route_df = base.extract_point_df(route_shp)
    _, elevation_gradient, _, _ = base.gradient(route_shp, rasterfile)
    gdf_route = base.make_multi_lines(linestring_route_df, elevation_gradient)
    if gdf_route.isnull().values.all():
        raise ValueError(
            'GeoDataFrame has some null value, check the sources.')
    else:
        pass
    return
コード例 #8
0
def route_analysis_metrics(route_num, shapefile, rasterfile):
    """
       input the number of route, then output the metrics calculated for that route. 
    Also will save the route as shapefile named 'route_shp'.
    
    Parameters
    ----------
    route_num: Desired route number (integer)
    shapefile: route geospatial data (.shp file)
    rasterfile: elevation data file (.tif)
    
    Returns
    -------
    display_metrics: results of metrics calculations
    """
    route_shp = base.read_shape(shapefile, route_num)
    
    linestring_route_df = base.extract_point_df(route_shp)
    
    elevation, elevation_gradient, route_cum_distance, distance = base.gradient(route_shp, rasterfile)
    
    display_metrics, _ = base.route_metrics(elevation, elevation_gradient, route_cum_distance, distance, route_num)
    
    return display_metrics