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

Allow Topojson dicts to be parsed into Topology #128

Merged
merged 8 commits into from
Sep 6, 2021

Conversation

mattijn
Copy link
Owner

@mattijn mattijn commented Sep 5, 2021

This PR will fix #124. This PR provides an enhancement by supporting reading topojson files. This enables loading Topojson structured json data into a Topology and process them further. Such as the following example:

import json
import topojson

# load topojson file into dict
with open("tests/files_topojson/nybb_from_mapshaper.topojson", 'r') as f:
    data = json.load(f)

# parse topojson file using `objects_name`
topo = topojson.Topology(data, objects_name="nybb")

# apply toposimplify, serialise into a geodataframe and plot
topo.toposimplify(5000).to_gdf().plot()

image

Not all functions are working yet (eg to_alt()), but it is a good start.

@mattijn
Copy link
Owner Author

mattijn commented Sep 6, 2021

Serializing to altair is included as well as more tests. Made sure all other tests are still passing

@mattijn mattijn merged commit 85b1e37 into master Sep 6, 2021
@mattijn mattijn deleted the parse_topojson_dicts branch September 6, 2021 20:58
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

Successfully merging this pull request may close these issues.

Converting a quantized topojson string to geojson fails to dequantize the coordinates
1 participant