Skip to content

Folium throwing a bunch of errors #209

Description

@LaurentBerder

Hi,

I'm just trying out PyMove because it seems like it could bring a lot to my current project.
But I can't get any folium functionality to work, though.

Here's an extract of what I'm doing:

df.head()
absolute_timelatlngid
2021-09-09 10:32:27.00045.8184593.13988754
2021-09-09 10:32:28.00045.8184593.13988754
2021-09-09 10:32:29.04445.8184593.13988754
2021-09-09 10:32:30.00045.8184593.13988754
2021-09-09 10:32:31.00045.8184593.13988754
move_df=MoveDataFrame(data=df, latitude='lat', longitude='lng', datetime='absolute_time')
frompymoveimportfoliumasff.plot_trajectories(move_df)
---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
<ipython-input-159-487305dba7d4>in<module>()
1frompymoveimportfoliumasf---->2f.plot_trajectories(move_df)
2frames/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.pyinplot_trajectories(move_data, n_rows, lat_origin, lon_origin, zoom_start, legend, base_map, tile, save_as_html, color, color_by_id, filename)
993994_add_trajectories_to_map(
-->995mv_df, items, base_map, legend, save_as_html, filename996 )
997/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.pyin_add_trajectories_to_map(move_data, items, base_map, legend, save_as_html, filename)
896mv=move_data[move_data[TRAJ_ID] ==_id]
897-->898_add_begin_end_markers_to_map(mv, base_map, color, _id)
899900folium.PolyLine(
/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.pyin_add_begin_end_markers_to_map(move_data, base_map, color, _id)
837popup='Início',
838icon=plugins.BeautifyIcon(
-->839icon='play', icon_shape='marker', background_color=coloror'green'840 )
841 ).add_to(points)
TypeError: __init__() gotanunexpectedkeywordargument'color'

Or if I just try to plot the bounding box, I get a different error.

f.plot_bbox(move_df.get_bbox(), color='blue')
---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
<ipython-input-161-03377951b622>in<module>()
---->1f.plot_bbox(move_df.get_bbox(), color='blue')
6frames/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.pyinplot_bbox(bbox_tuple, base_map, tiles, color, save_as_html, filename)
1688base_map=folium.Map(tiles=tiles)
1689base_map.fit_bounds(
->1690 [[bbox_tuple[0], bbox_tuple[1]], [bbox_tuple[2], bbox_tuple[3]]]
1691 )
1692points_= [
/usr/local/lib/python3.7/dist-packages/folium/folium.pyinfit_bounds(self, bounds, padding_top_left, padding_bottom_right, padding, max_zoom)
411'Choropleth class, which has the same arguments. See the example '412'notebook \'GeoJSON_and_choropleth\' for how to do this.',
-->413FutureWarning414 )
415fromfolium.featuresimportChoropleth/usr/local/lib/python3.7/dist-packages/folium/map.pyin__init__(self, bounds, padding_top_left, padding_bottom_right, padding, max_zoom)
456Boundingboxspecifiedastwopoints [southwest, northeast]
457padding_top_left: (x, y) point, defaultNone-->458Paddinginthetopleftcorner. Usefulifsomeelementsin459thecorner, suchascontrols, mightobscureobjectsyou'rezooming460to.
/usr/lib/python3.7/json/__init__.pyindumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
229clsisNoneandindentisNoneandseparatorsisNoneand230defaultisNoneandnotsort_keysandnotkw):
-->231return_default_encoder.encode(obj)
232ifclsisNone:
233cls=JSONEncoder/usr/lib/python3.7/json/encoder.pyinencode(self, o)
197# exceptions aren't as detailed. The list call should be roughly198# equivalent to the PySequence_Fast that ''.join() would do.-->199chunks=self.iterencode(o, _one_shot=True)
200ifnotisinstance(chunks, (list, tuple)):
201chunks=list(chunks)
/usr/lib/python3.7/json/encoder.pyiniterencode(self, o, _one_shot)
255self.key_separator, self.item_separator, self.sort_keys,
256self.skipkeys, _one_shot)
-->257return_iterencode(o, 0)
258259def_make_iterencode(markers, _default, _encoder, _indent, _floatstr,
/usr/lib/python3.7/json/encoder.pyindefault(self, o)
177178 """
--> 179 raise TypeError(f'Object of type {o.__class__.__name__} '
180 f'is not JSON serializable')
181 TypeError: Object of type float16 is not JSON serializable

I'm using python version 3.7, PyMove version 3.0.0, and folium version 0.8.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions