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

Add bbox on the index, add topoquantize and chaining of toposimplify and topoquantize #36

Merged
merged 2 commits into from
Aug 10, 2019

Conversation

mattijn
Copy link
Owner

@mattijn mattijn commented Aug 10, 2019

This PR adds the ability to apply topoquantization (topoquantize). Therefor it was necessary to have bbox as key in the object.

Also chaining of the toposimplify() and topoquantize() functions is possible now.

This is coded as follow:

import geopandas
import topojson
data = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
data = data[(data.continent == "Africa")]
tj = topojson.Topology(data, options={'prequantize':1e6, 'topology':True})
tj.toposimplify(2.9).topoquantize(1e4).to_alt()

output_2_0

Or interactively using ipywidgets:

from ipywidgets import interact, fixed
import ipywidgets as widgets
style = {'description_width': 'initial'}
eps = widgets.FloatSlider(min=0, max=10, step=0.1, value=0, description='Toposimplify Factor', style=style)
qnt = widgets.FloatLogSlider(value=1e6, base=10, min=1,max=6,step=0.5, description='Topoquantize Factor', style=style)

def toposimpquant(epsilon, quant, topo):
    return topo.toposimplify(epsilon).topoquantize(quant).to_alt()

interact(toposimpquant, epsilon=eps, quant=qnt, topo=fixed(tj))

Gif output:
toposimplify_topoquantize

@mattijn mattijn merged commit 713a9f1 into master Aug 10, 2019
@mattijn mattijn mentioned this pull request Aug 10, 2019
8 tasks
@mattijn mattijn deleted the bbox-topoquantize-chaining branch January 17, 2020 20:25
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.

None yet

1 participant