-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
support for multiple gdf and geojson as input #169
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BTW. Reading of topojson files that includes multiple objects is already supported: with open(r'tests/files_topojson/gm.topo.json') as f:
topo_file = json.load(f)
topo_nl = Topology(topo_file, object_name='nl_features')
topo_gm = Topology(topo_file, object_name='gm_features')
topo_nl.to_alt(projection='mercator') topo_gm.to_alt(projection='mercator') |
Goal is to support the following approach: import geopandas as gpd
from topojson import Topology
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world[['continent', 'geometry', 'pop_est']]
continents = world.dissolve(by='continent', aggfunc='sum')
Topology(
data=[world, continents],
object_name=['world', 'continents']
) |
I like this feature. Check the following: import geopandas as gpd
from topojson import Topology
import altair as alt
africa_countries = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres")).query('continent == "Africa"')
africa_continent = africa_countries.dissolve(by='continent', aggfunc='sum').reset_index()
topo = Topology(
data=[africa_countries, africa_continent],
object_name=['countries', 'continent']
) # disable dataset consolidation
# see https://altair-viz.github.io/user_guide/data_transformers.html#dataset-consolidation
alt.data_transformers.consolidate_datasets = False
# simplify the topology in once for both objects and visualise
topo.toposimplify(5, inplace=True)
topo.to_alt(object_name='continent') | topo.to_alt(object_name='countries') |
mattijn
changed the title
support for multiple gdf as input
support for multiple gdf and geojson as input
Sep 4, 2022
Accidentally commit to master instead from a PR. This commit e32cfc3 provides support for multiple geojson objects as input. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP. This PR aims to support multiple geodataframes as input to store it in a single topojson file.
Eg. combination of global continent-level and country-level data.