Beispiel #1
0
    def __init__(self, shapefile=Path("assets/wrs/WRS2_descending.shp")):
        speedups.disable()
        self.shapefile = ogr.Open(str(shapefile))
        self.layer = self.shapefile.GetLayer(0)

        self.polygons = []

        for i in range(self.layer.GetFeatureCount()):
            feature = self.layer.GetFeature(i)
            path = feature['PATH']
            row = feature['ROW']
            geom = feature.GetGeometryRef()
            shape = shapely.wkt.loads(geom.ExportToWkt())
            self.polygons.append((shape, path, row))
Beispiel #2
0
# Here I apply a global model on bus OD data in Singapore. The bus OD data is a small subset of bus trip data available via LTA Data Mall: https://datamall.lta.gov.sg/content/datamall/en.html. Preprocessing has been performed by matching O/D to bus stop locations, and line features connecting each pair of OD are created. Weight column carries the expected volume of passengers on the pair of OD nodes.
#
# %% [markdown]
# ## Global Model

# %%
import geopandas as gpd
import networkx as nx
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os, sys

# %%
from shapely import speedups
speedups.disable()

# %%
# import line shapefile (representing OD flows between each pair of bus stops)
orig_flow = gpd.read_file(r"data\SampleODFlow.shp")
orig_flow.head()

# %%
orig_flow.info()

# %%
orig_flow.plot(linewidth=0.5, alpha=0.01)

# %% [markdown]
# Some of the nodes are in erroneous locations (X/Y of 0,0). We will remove these OD links from the dataset.
Beispiel #3
0
 def tearDown(self):
     self.assertTrue(speedups._orig)
     speedups.disable()
     self.assertFalse(speedups._orig)
 def tearDown(self):
     self.assertTrue(speedups._orig)
     speedups.disable()
     self.assertFalse(speedups._orig)