Skip to content

Commit

Permalink
fix step-1 resolve deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
elbeejay committed Mar 7, 2024
1 parent d2d5e08 commit 13a5385
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
26 changes: 13 additions & 13 deletions Tutorials/Step_1-Extract_From_OSM.ipynb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## note: As of Jan 21, 2020 This tutorial is using the GOSTnets version from this repo's master branch. Make sure that the GOSTnets version from PyPi is uninstalled and that you are pointing your path to the correct location of the library."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -23,8 +16,7 @@
"outputs": [],
"source": [
"import geopandas as gpd\n",
"import os\n",
"import sys"
"import os"
]
},
{
Expand All @@ -43,8 +35,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Add to your system path the location of the LoadOSM.py and GOSTnet.py scripts. \n",
"In this case, we use relative paths (\"..\") to locate the parent directory (one level up). One dot (\".\") means current directory."
"Import the GOSTnets library as gn."
]
},
{
Expand All @@ -53,7 +44,6 @@
"metadata": {},
"outputs": [],
"source": [
"sys.path.append(\"../\")\n",
"import GOSTnets as gn"
]
},
Expand Down Expand Up @@ -271,7 +261,7 @@
"outputs": [],
"source": [
"iceland.roads_raw = iceland.roads_raw.loc[\n",
" iceland.roads_raw.geometry.intersects(clip_shp_obj) is True\n",
" iceland.roads_raw.geometry.intersects(clip_shp_obj) == True # noqa: E712\n",
"]"
]
},
Expand All @@ -291,6 +281,16 @@
"iceland.generateRoadsGDF(verbose=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# view the first 5 rows of the newly created roads GeoDataFrame\n",
"iceland.roadsGPD.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
3 changes: 2 additions & 1 deletion src/GOSTnets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import warnings
import time
import pickle as pkl

import pyproj
import networkx as nx
Expand Down Expand Up @@ -1891,7 +1892,7 @@ def save(G, savename, wpath, pickle=True, edges=True, nodes=True):
new_edge_gdf = edge_gdf_from_graph(G)
new_edge_gdf.to_csv(os.path.join(wpath, "%s_edges.csv" % savename))
if pickle is True:
nx.write_gpickle(G, os.path.join(wpath, "%s.pickle" % savename))
pkl.dump(G, open(os.path.join(wpath, "%s.pickle" % savename), "wb"))


def add_missing_reflected_edges(G, one_way_tag=None, verbose=False):
Expand Down
6 changes: 3 additions & 3 deletions src/GOSTnets/load_osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def line_length(self, line, ellipsoid="WGS-84"):
Length of line in kilometers
"""
if line.geometryType() == "MultiLineString":
if line.geom_type == "MultiLineString":
return sum(self.line_length(segment) for segment in line)

return sum(
Expand Down Expand Up @@ -398,9 +398,9 @@ def get_all_intersections(
# Save intersecting point
# updating to be compatible with Shapely ver 2
# if "Point" == inter.type:
if "Point" == inter.type:
if "Point" == inter.geom_type:
idx_inters.insert(0, inter.bounds, inter)
elif "MultiPoint" == inter.type:
elif "MultiPoint" == inter.geom_type:
# updating to be compatible with Shapely ver 2
# for pt in inter:
for pt in inter.geoms:
Expand Down

0 comments on commit 13a5385

Please sign in to comment.