Giter Site home page Giter Site logo

Comments (8)

mattijn avatar mattijn commented on May 28, 2024 1

I'm happy this issue is resolved. Its fun to play with this.

import topojson as tp
import geopandas as gpd

world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
tp.Topology(data=world).toposimplify(4).topoquantize(20).to_alt(color='properties.name:N')

image

from topojson.

mattijn avatar mattijn commented on May 28, 2024 1

I've to admit it's not fast.

import topojson as tp
import geopandas as gpd
import matplotlib.pyplot as plt

brexit = gpd.read_file('/Users/mattijnvanhoek/Downloads/brexit.gpkg')
topo = tp.Topology(brexit)

q100 = topo.topoquantize(100).to_gdf()
q250 = topo.topoquantize(250).to_gdf()
q500 = topo.topoquantize(500).to_gdf()

f, ax = plt.subplots(1, 3, figsize=(10, 10))
q100.plot(ax=ax[0])
q250.plot(ax=ax[1])
q500.plot(ax=ax[2])

image

Would indeed be good to investigate routes for quantization through pygeos as well, like in this comment geopandas/geopandas#1727 (comment)

from topojson.

ljwolf avatar ljwolf commented on May 28, 2024

We're seeing these issues as well.
Screenshot_20201201_160248

brexit.gpkg.zip

Interested in digging into this...

from topojson.

mattijn avatar mattijn commented on May 28, 2024

Thanks for your interest in this issue. At this place in the docs https://mattijn.github.io/topojson/example/settings-tuning.html#prequantize I've worked out the quantization process in 1D.

I see you have linked this issue to another at the geopandas repo. Im still figuring out what is going wrong here. Maybe your usecase is a smaller reproducible example.

from topojson.

mattijn avatar mattijn commented on May 28, 2024

Found a use-case small enough for debugging:

import topojson as tp
import geopandas as gpd

gdf = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
gdf = gdf[gdf.name.isin(['France', 'Belgium', 'Netherlands'])]
tp.Topology(data=gdf).toposimplify(4).topoquantize(500).to_alt(color='properties.name:N')

image

from topojson.

mattijn avatar mattijn commented on May 28, 2024

Thanks again for commenting in order to bring this issue on my radar again!

This issue is fixed by #116, linestrings which can become points due filtering of repeating coordinates that were not written back to the linestring. After delta-encoding the start-coordinates of quantised linestrings got mixed up with this case.

During debugging I found out that the overal bbox is not regenerated after simplification and quantization. Filled #117 for this.

from topojson.

ljwolf avatar ljwolf commented on May 28, 2024

If you're game for a numba implementation, I'm sure that'd help accelerate things? I prefer working on the topojson-style data structure, and numba could work well with ragged arrays stored as lists of tuples.

from topojson.

mattijn avatar mattijn commented on May 28, 2024

This is discussed previously with @Casyfill and might be a good method indeed to improve speed further. It might be very simple to get good results, but I've never tried it. Let me open a new issue so it can be tracked.

from topojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.