Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when generating routed speeds geodataframe #154

Open
ana-kop opened this issue Oct 26, 2022 · 0 comments
Open

Error when generating routed speeds geodataframe #154

ana-kop opened this issue Oct 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@ana-kop
Copy link
Contributor

ana-kop commented Oct 26, 2022

The error appeared when generating standard outputs for updated Sheffield network using the following command:

n.generate_standard_outputs('/mnt/efs/networks/loyal-tint/fixed_schedule_2/standard_outputs')

The error message:

2022-10-26 11:43:30,925 - Right now routed speeds do not account for services snapping to long network links. Be sure to account for that in your investigations and check the non-routed `pt_speeds`output as well.
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/.local/lib/python3.8/site-packages/pandas/core/series.py in __setitem__(self, key, value)
   1061         try:
-> 1062             self._set_with_engine(key, value)
   1063         except (KeyError, ValueError):
​
~/.local/lib/python3.8/site-packages/pandas/core/series.py in _set_with_engine(self, key, value)
   1094         # fails with AttributeError for IntervalIndex
-> 1095         loc = self.index._engine.get_loc(key)
   1096         # error: Argument 1 to "validate_numeric_casting" has incompatible type
​
~/.local/lib/python3.8/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
​
~/.local/lib/python3.8/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
​
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
​
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
​
KeyError: 'geometry'
​
During handling of the above exception, another exception occurred:
​
NotImplementedError                       Traceback (most recent call last)
<ipython-input-47-17011cd6dba8> in <module>
----> 1 n.generate_standard_outputs('/mnt/efs/networks/loyal-tint/fixed_schedule_2/standard_outputs')
​
/mnt/efs/networks/genet-lib/genet/genet/core.py in generate_standard_outputs(self, output_dir, gtfs_day, include_shp_files)
   2137         :return: None
   2138         """
-> 2139         geojson.generate_standard_outputs(self, output_dir, gtfs_day, include_shp_files)
   2140         logging.info('Finished generating standard outputs. Zipping folder.')
   2141         persistence.zip_folder(output_dir)
​
/mnt/efs/networks/genet-lib/genet/genet/output/geojson.py in generate_standard_outputs(n, output_dir, gtfs_day, include_shp_files, schedule_network_factor)
    223     # schedule outputs
    224     if n.schedule:
--> 225         generate_standard_outputs_for_schedule(
    226             n.schedule,
    227             output_dir=os.path.join(output_dir, 'schedule'),
​
/mnt/efs/networks/genet-lib/genet/genet/output/geojson.py in generate_standard_outputs_for_schedule(schedule, output_dir, gtfs_day, include_shp_files, schedule_network_factor, gdf_network_links)
    128     logging.info(f'Generating stop-to-stop speed outputs with network_factor={schedule_network_factor}')
    129     speed_dir = os.path.join(output_dir, 'speed')
--> 130     speeds_gdf = schedule.speed_geodataframe(
    131         network_factor=schedule_network_factor, gdf_network_links=gdf_network_links)
    132     save_geodataframe(
​
/mnt/efs/networks/genet-lib/genet/genet/schedule_elements.py in speed_geodataframe(self, network_factor, gdf_network_links)
    305         df['speed'] = df['distance'] / df['time']
    306         if gdf_network_links is not None:
--> 307             network_distance_df = use_schedule.network_routed_distance_gdf(self, gdf_network_links)
    308             df = gpd.GeoDataFrame(
    309                 df.merge(
​
/mnt/efs/networks/genet-lib/genet/genet/use/schedule.py in network_routed_distance_gdf(schedule, gdf_network_links)
    205     ).assign(route=np.concatenate(routes_df['route'].values), sequence=np.concatenate(routes_df['sequence'].values))
    206     routes_df = routes_df.merge(gdf_network_links[['length', 'geometry']], left_on='route', right_index=True)
--> 207     return routes_df.groupby(['id', 'from_stop', 'to_stop']).apply(combine_route).reset_index(drop=True)
​
~/.local/lib/python3.8/site-packages/pandas/core/groupby/groupby.py in apply(self, func, *args, **kwargs)
   1270         with option_context("mode.chained_assignment", None):
   1271             try:
-> 1272                 result = self._python_apply_general(f, self._selected_obj)
   1273             except TypeError:
   1274                 # gh-20949
​
~/.local/lib/python3.8/site-packages/pandas/core/groupby/groupby.py in _python_apply_general(self, f, data)
   1304             data after applying f
   1305         """
-> 1306         keys, values, mutated = self.grouper.apply(f, data, self.axis)
   1307 
   1308         return self._wrap_applied_output(
​
~/.local/lib/python3.8/site-packages/pandas/core/groupby/ops.py in apply(self, f, data, axis)
    818             # group might be modified
    819             group_axes = group.axes
--> 820             res = f(group)
    821             if not _is_indexed_like(res, group_axes, axis):
    822                 mutated = True
​
/mnt/efs/networks/genet-lib/genet/genet/use/schedule.py in combine_route(group)
    172         length = group['length'].sum()
    173         group = group.iloc[0, :][['id', 'from_stop', 'to_stop']]
--> 174         group['geometry'] = geom
    175         group['network_distance'] = length
    176         return group
​
~/.local/lib/python3.8/site-packages/pandas/core/series.py in __setitem__(self, key, value)
   1068             else:
   1069                 # GH#12862 adding a new key to the Series
-> 1070                 self.loc[key] = value
   1071 
   1072         except TypeError as err:
​
~/.local/lib/python3.8/site-packages/pandas/core/indexing.py in __setitem__(self, key, value)
    721 
    722         iloc = self if self.name == "iloc" else self.obj.iloc
--> 723         iloc._setitem_with_indexer(indexer, value, self.name)
    724 
    725     def _validate_key(self, key, axis: int):
​
~/.local/lib/python3.8/site-packages/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value, name)
   1722 
   1723             if missing:
-> 1724                 self._setitem_with_indexer_missing(indexer, value)
   1725                 return
   1726 
​
~/.local/lib/python3.8/site-packages/pandas/core/indexing.py in _setitem_with_indexer_missing(self, indexer, value)
   1996 
   1997             # this preserves dtype of the value
-> 1998             new_values = Series([value])._values
   1999             if len(self.obj._values):
   2000                 # GH#22717 handle casting compatibility that np.concatenate
​
~/.local/lib/python3.8/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    437                     data = data.copy()
    438             else:
--> 439                 data = sanitize_array(data, index, dtype, copy)
    440 
    441                 manager = get_option("mode.data_manager")
​
~/.local/lib/python3.8/site-packages/pandas/core/construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure, allow_2d)
    569             subarr = _try_cast(data, dtype, copy, raise_cast_failure)
    570         else:
--> 571             subarr = maybe_convert_platform(data)
    572             if subarr.dtype == object:
    573                 subarr = cast(np.ndarray, subarr)
​
~/.local/lib/python3.8/site-packages/pandas/core/dtypes/cast.py in maybe_convert_platform(values)
    116 
    117     if isinstance(values, (list, tuple, range)):
--> 118         arr = construct_1d_object_array_from_listlike(values)
    119     else:
    120         # The caller is responsible for ensuring that we have np.ndarray
​
~/.local/lib/python3.8/site-packages/pandas/core/dtypes/cast.py in construct_1d_object_array_from_listlike(values)
   1988     # making a 1D array that contains list-likes is a bit tricky:
   1989     result = np.empty(len(values), dtype="object")
-> 1990     result[:] = values
   1991     return result
   1992 
​
~/.local/lib/python3.8/site-packages/shapely/geometry/base.py in __array_interface__(self)
    852     def __array_interface__(self):
    853         """Provide the Numpy array protocol."""
--> 854         raise NotImplementedError("Multi-part geometries do not themselves "
    855                                   "provide the array interface")
    856 
​
NotImplementedError: Multi-part geometries do not themselves provide the array interface
@ana-kop ana-kop added the bug Something isn't working label Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant