gpdvega
gpdvega copied to clipboard
wrong 'Antarctica'
import altair as alt
import geopandas as gpd
import gpdvega
alt.renderers.enable('notebook') # render for Jupyter Notebook
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
# GeoDataFrame could be passed as usual pd.DataFrame
alt.Chart(world[world.continent=='Antarctica']).mark_geoshape(
stroke='#1f77b4',
fill='#7f7f7f',
fillOpacity=0.3
).project(
).encode(
).properties(
width=500,
height=300
)
but
world[world.continent=='Antarctica'].plot()
It's both sides issue. Geopandas
Antarctica contains point (180.00000000000014, -90.00000000000003)
which is not valid. And Vega
do not interpret it as expected.
- [x] workaround
- [x] issue downstream
- [x] https://github.com/geopandas/geopandas/issues/804
- [ ] https://github.com/vega/vega/issues/1405
So current workaround is to cut Antarctica with correct box.
import altair as alt
import geopandas as gpd
import gpdvega
alt.renderers.enable('notebook') # render for Jupyter Notebook
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
#workaround
world.set_geometry( world.geometry.intersection(sh.geometry.box(-180,-90,180,90)),inplace=True)
alt.Chart(world).mark_geoshape(
stroke='#1f77b4',
fill='#7f7f7f',
fillOpacity=0.3
).project(
).encode(
).properties(
width=500,
height=300
)