def save_graph_geopackage(
    G: nx.MultiDiGraph,
    filepath: str | Path | None = None,
    *,
    directed: bool = False,
    encoding: str = "utf-8",
) -> None:
    """
    Save graph nodes and edges to disk as layers in a GeoPackage file.

    Parameters
    ----------
    G
        The graph to save.
    filepath
        Path to the GeoPackage file including extension. If None, use default
        `settings.data_folder/graph.gpkg`.
    directed
        If False, save one edge for each undirected edge in the graph but
        retain original oneway and to/from information as edge attributes. If
        True, save one edge for each directed edge in the graph.
    encoding
        The character encoding of the saved GeoPackage file.
    """
    # default filepath if none was provided
    filepath = Path(settings.data_folder) / "graph.gpkg" if filepath is None else Path(filepath)

    # if save folder does not already exist, create it
    filepath.parent.mkdir(parents=True, exist_ok=True)

    # convert graph to gdfs and stringify non-numeric columns
    if directed:
        gdf_nodes, gdf_edges = convert.graph_to_gdfs(G)
    else:
        gdf_nodes, gdf_edges = convert.graph_to_gdfs(convert.to_undirected(G))
    gdf_nodes = _stringify_nonnumeric_cols(gdf_nodes)
    gdf_edges = _stringify_nonnumeric_cols(gdf_edges)

    # save the nodes and edges as GeoPackage layers
    gdf_nodes.to_file(filepath, layer="nodes", driver="GPKG", index=True, encoding=encoding)
    gdf_edges.to_file(filepath, layer="edges", driver="GPKG", index=True, encoding=encoding)

    msg = f"Saved graph as GeoPackage at {str(filepath)!r}"
    utils.log(msg, level=lg.INFO)

    Save graph nodes and edges to disk as layers in a GeoPackage file.

    Parameters
    ----------
    G
        The graph to save.
    filepath
        Path to the GeoPackage file including extension. If None, use default
        `settings.data_folder/graph.gpkg`.
    directed
        If False, save one edge for each undirected edge in the graph but
        retain original oneway and to/from information as edge attributes. If
        True, save one edge for each directed edge in the graph.
    encoding
        The character encoding of the saved GeoPackage file.
    
osmnx/io.py