Skip to content
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

Merge multiple layers in a single topojson #147

Closed
kvalev opened this issue Dec 19, 2021 · 5 comments
Closed

Merge multiple layers in a single topojson #147

kvalev opened this issue Dec 19, 2021 · 5 comments

Comments

@kvalev
Copy link

kvalev commented Dec 19, 2021

Hey, I am trying to merge multiple geojson feature collections to a single topojson, but I cant seem to get it running.

I tried both:

objects = {
   "regions": regions_geojson,
   "municipalities": municipalities_geojson,
}

tp.Topology(objects)

and

tp.Topology([regions_geojson, municipalities_geojson])

but neither of them worked. Is this use case supported?

@mattijn
Copy link
Owner

mattijn commented Dec 19, 2021

No, that is not supported. But it would be cool. I know topojson supports multiple layers with single declared arcs, but I don't know what a good approach would be to handle this usecase. Any suggestions or approaches are much welcome!

@kvalev
Copy link
Author

kvalev commented Dec 20, 2021

Thanks for the quick response! Unfortunately, I wont be of much help, as I am very much a newbie wrt to topojson. I just stumbled upon it, because one data visualization tool requires it.

@natsuapo
Copy link
Contributor

One simple solution: you can first merge the geojsons / geo-dataframes together and distinguish them by adding one field. Then in the generated topojson dict, replace the single object by creating a dict based on the field you created.

@mattijn
Copy link
Owner

mattijn commented Apr 7, 2022

@natsuapo, simple but effective. Sounds like an idea worth trying!

@mattijn
Copy link
Owner

mattijn commented Aug 26, 2022

This is now supported by means of multiple geo-dataframes per #169 and is documented here: https://mattijn.github.io/topojson/example/input-types.html#list-of-geodataframes.

Usage for above mentioned example can be declared as such:

from topojson import Topology
topo = Topology(
    data=[regions, municipalities],  # can be either a GeoDataFrame or a GeoJSON FeatureCollection  
    object_name=['regions', 'municipalities']
)

Documentation is here:

@mattijn mattijn closed this as completed Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants