altair
altair copied to clipboard
Geoshape docs revamp 5.0
As per https://github.com/joelostblom/altair/pull/1#issuecomment-1271143450.
I just changed the base repository to merge into, but I'm not sure if this will result in merge errors. Can you check @joelostblom if this works for you once starting with https://github.com/altair-viz/altair/pull/2607?
Note, I remember seeing this, https://github.com/altair-viz/altair/issues/2651#issuecomment-1176581865 example from you. It would be nice to integrate thhat as well.
I tried it using geopandas, but did not really succeed:
import altair as alt
import geopandas as gpd
import json
gdf_ne = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
extent_africa = gdf_ne.query("continent == 'Africa'").unary_union.envelope
fit_africa = json.loads(gpd.GeoSeries([extent_africa]).to_json())['features']
# this does not work
alt.Chart(gdf_ne).mark_geoshape(clip=True).project(fit=fit_africa)
# but this does a bit better.. not sure why
del fit_africa[0]['geometry']['coordinates'][0][0][0]
alt.Chart(gdf_ne).mark_geoshape(clip=True).project(fit=fit_africa)
Also not sure if this all should be within the mark geoshape documentation
Great, thanks @mattijn ! I will try this out when starting to work on the other PR (and also try to experiment with the additional example). Could you rebase this PR on current master branch? I think that will get rid of all my commits here that we already squash merged in #2566
Yes, @joelostblom. After some fight with git, I think I've rebased properly with the current main branch of altair repo.