Skip to content

Geo interface #880

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

Merged
merged 1 commit into from
Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Added BeautifyIcon Plugin (arthuralvim and jeremybyu #819)
- Explicit WMSTileLayer options, accept all **kwargs (conengmo #838)
- Updated links to Draw plugin (conengmo #868)
- Ingest any object that __geo_interface__ (ocefpaf #880)

API changes

Expand Down
423 changes: 423 additions & 0 deletions examples/Geopandas and geo_interface.ipynb

Large diffs are not rendered by default.

373 changes: 0 additions & 373 deletions examples/Geopandas.ipynb

This file was deleted.

14 changes: 4 additions & 10 deletions folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,11 @@ def __init__(self, data, style_function=None, name=None,
else: # This is a filename
with open(data) as f:
self.data = json.loads(f.read())
elif data.__class__.__name__ in ['GeoDataFrame', 'GeoSeries']:
elif hasattr(data, '__geo_interface__'):
self.embed = True
if hasattr(data, '__geo_interface__'):
# We have a GeoPandas 0.2 object.
self.data = json.loads(json.dumps(data.to_crs(epsg='4326').__geo_interface__)) # noqa
elif hasattr(data, 'columns'):
# We have a GeoDataFrame 0.1
self.data = json.loads(data.to_crs(epsg='4326').to_json())
else:
msg = 'Unable to transform this object to a GeoJSON.'
raise ValueError(msg)
if hasattr(data, 'to_crs'):
data = data.to_crs(epsg='4326')
self.data = json.loads(json.dumps(data.__geo_interface__)) # noqa
else:
raise ValueError('Unhandled object {!r}.'.format(data))

Expand Down