Comments (8)
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')
from topojson.
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])
Would indeed be good to investigate routes for quantization through pygeos as well, like in this comment geopandas/geopandas#1727 (comment)
from topojson.
We're seeing these issues as well.
Interested in digging into this...
from topojson.
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.
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')
from topojson.
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.
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.
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)
- Conversion to Typology object causes overlaps HOT 5
- tp.Topology.to_json(pretty=True) doesn't handle None correctly. (Doens't convert None to null) HOT 1
- Converting GeoJSON FeatureCollection to TopoJSON HOT 1
- BUG: `Topology.to_gdf` should keep the original index HOT 2
- holes in multipolygons are lost by simplification HOT 4
- Deprecation warning for shapely 2.0 HOT 3
- Wrong topologies/arcs being created? HOT 7
- Creating a topology for data without junctions and shared_coords=False, prequantize=False gives error
- Bug: polygons that entirely fill islands in another polygon are often not dedupped
- shared_coords=True vs shared_coords=False HOT 5
- Linestrings that follow the same path but where one contains extra redundant points are not deduplicated
- enh: include features that are possible with shapely 2.0
- tests failing, natural earth dataset changed HOT 2
- RuntimeWarning: invalid value encountered in cast HOT 3
- IndexError: pop index out of range when instanciating Topology with a list of GeoDataFrame HOT 10
- Coordinates not reported correctly on Multipoint with only one point HOT 2
- Excessive memory usage with prequantization enabled HOT 5
- serialize_as_geojson outputs invalid GeoJSON HOT 2
- Topojson >=1.6 requires Python >=3.8, but there is no guard against Python <3.8 HOT 2
- Feature: Use geojson feature/geometry id if exists HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from topojson.