-
Notifications
You must be signed in to change notification settings - Fork 31
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
lonboard backend for geopandas explore #412
base: main
Are you sure you want to change the base?
Conversation
lonboard is wicked flexible as a widget and can update the map (e.g. change colors, add layers) on the fly and without redrawing that map, which makes it relatively simple to implement an interactive version of the animated maps, like with something as simple as from time import sleep
for i in range(10):
for color in ['yellow','red', 'blue']:
m.layers[0].get_fill_color = color
sleep(.5)
sleep(1) and you could very easily add widgets that control the speed of animation, etc |
following martin's suggestion, it would be cool to implement the plotting (this, the animation, and the timeseries plot--maybe others) as methods on a geodataframe https://pandas.pydata.org/docs/development/extending.html using the extension framework when we first started geosnap, everything used a clumsy class-based approach that was little more than a wrapper around a geodataframe because the extension api wasn't available at the time |
ok this is pretty neat actually. The latest commit moves the function into an explore method under the gvz namespace, e.g.
fixed a scalar issue with non-classified maps, so the API is identical as possible and both produce identical results. The only remaining difference is you still cant use continuous colormaps with categorical data--which again, I think is ok but could still probably be solved easily full demo notebook here but the lonboard maps don't get embedded https://gist.github.com/knaaptime/6f6c4f1ae7ce6b156b4cfbcc6b029f98 |
categorical maps can take any cmap now (even animation works as expected). Pretty sure this is as close to matching vanilla (though welcome any input if you have any) |
from a quick glance looks okay to me |
add explore-like function to generate a lonboard choropleth quickly from a geodataframe. It needs testing and a few checks (like checking length if passing
color
directly instead of a string) but otherwise has parity, essentially withgdf.explore
.The lonboard linear scaler works a little differently than the default explore (I don't think the discrepancy is wrong, just different implementations), but the purpose here is really to use mapclassify, so I'm not too concerned. Some things may not be perfectly in sync withexplore
, for instance categorical maps will throw an error if you try to plot with a continuous colormap. While catching that might be good, I'm fine with that (correct) behavior as default.