urbanaccess icon indicating copy to clipboard operation
urbanaccess copied to clipboard

ua.network.integrate_network drops transit_nodes.stop_names

Open SKalt opened this issue 8 years ago • 3 comments

Description of the bug

calling with downloaded osm network data overwrites the network's transit_nodes.stop_names

GTFS feed or OSM data (optional)

While I think this issue is pandas-only, for the sake of testing, here's what I used: bbox=(-72.720566,42.221907,-72.464134,42.441194) {'gtfs_feeds': {'PVTA': 'http://www.gtfs-data-exchange.com/agency/pvta/latest.zip'}}

Environment

  • Operating system: Ubuntu 16.04
  • Python version: 2.7
  • UrbanAccess version: 0.1a
  • UrbanAccess required packages versions (optional):

Paste the code that reproduces the issue here:

# ripped nearly exactly from the demo
import urbanaccess as ua
from urbanaccess.config import settings
from urbanaccess.gtfsfeeds import feeds
from urbanaccess import gtfsfeeds
from urbanaccess.gtfs.gtfsfeeds_dataframe import gtfsfeeds_dfs
from urbanaccess.network import ua_network, load_network

settings.log_console = True
# main 
gtfsfeeds.search(search_text='Pioneer Valley',
                 search_field=None,
                 match='contains',
                 add_feed=True,
                 overwrite_feed=True)
gtfsfeeds.download()
validation = True
verbose = True
append_definitions = True
bbox=(-72.720566,42.221907,-72.464134,42.441194)

loaded_feeds = ua.gtfs.load.gtfsfeed_to_df(
    gtfsfeed_path=None,
    validation=validation,
    bbox=bbox,
    remove_stops_outsidebbox=True,
    verbose=verbose,
    append_definitions=append_definitions
)

ua.gtfs.network.create_transit_net(
    gtfsfeeds_dfs=loaded_feeds,
    day='monday',
    timerange=['07:00:00', '10:00:00'],
    calendar_dates_lookup=None
)
urbanaccess_net = ua.network.ua_network
nodes, edges = ua.osm.load.ua_network_from_bbox(
    bbox=bbox,
    remove_lcn=True
)
ua.osm.network.create_osm_net(
    osm_edges=edges,
    osm_nodes=nodes,
    travel_speed_mph=3
)
ua.gtfs.headways.headways(
    gtfsfeeds_df=loaded_feeds,
    headway_timerange=['07:00:00','10:00:00']
)
ua.network.integrate_network(
    urbanaccess_network=urbanaccess_net,
    headways=True,
    urbanaccess_gtfsfeeds_df=loaded_feeds,
    headway_statistic='mean'
)

Commenting ua.network.integrate_network(...) retains the stop_names in urbanaccess_net.transit_nodes. loaded_feeds retains stop_names.

SKalt avatar Jul 02 '17 15:07 SKalt

I tried integrating the osm_net before integrating the headways, as in the demo.ipynb, but it yielded the same result. The deletion of stop_names still occurs at integrate_network with headways=True, urbanaccess_gtfsfeeds_df=loaded_feeds. I've noticed the from and to columns in net_edges are now concatenations of the original stop ids and unique_route_ids.

SKalt avatar Jul 02 '17 16:07 SKalt

I found the code at fault around network.py line 153, where transit_edges.from and .to, are overwritten, as is transit_nodes with _route_id_to_node. I'd recommend retaining the original node ids in separate column for joining on the feeds.stop_id.

SKalt avatar Jul 03 '17 14:07 SKalt

Thanks @SKalt we will look into making this change in the next version.

sablanchard avatar Aug 01 '17 20:08 sablanchard