Comments (4)
Hi! Regarding speedups, correct me if I'm wrong.
Great speed-up might be achieved by parallelization of this loop: https://github.com/mattijn/topojson/blob/master/topojson/ops.py#L627
from topojson.
Thanks for commenting! This might be one of the locations that can be parallelized if simplification is a bottleneck for you. In my experience the computation of the Topology itself is sometimes more troublesome.
The line you point to is for shapely simplification, it is also possible to use the optional package simplification
, see https://mattijn.github.io/topojson/example/settings-tuning.html#simplify_algorithm.
Although that is also a for-loop: https://github.com/mattijn/topojson/blob/master/topojson/ops.py#L635.
Another option to speedup pre/topo-simplification is too see how shapely 2.0 (pygeos) will perform. If there is support for ragged-arrays than the simplification of linestrings/arcs can probably be done on array level in C.
from topojson.
Comparison against https://strk.kbt.io/blog/2012/04/13/simplifying-a-map-layer-using-postgis-topology/
Simplifying a map layer using PostGIS topology
Posted on 13 April, 2012
Total seconds ~13, vertices down to 1369 (from 47036).
Python topojson timing:
Total milliseconds ~457, vertices down to 1015. ~28x faster. Maybe due to better hardware.
Used code
import topojson as tp
import geopandas as gpd
import numpy as np
gdf = gpd.read_file(r"https://www.geotests.net/cours/sigma/webmapping/donnees_pg/GEOFLADept_FR_Corse_AV_L93.zip")
gdf.head()
# building topology
topo = tp.Topology(gdf, prequantize=3000) # 270ms
# apply simplify on arcs
topo = topo.toposimplify(10000) # 164ms
# visualize
topo.to_alt() # 94ms
# or as oneliner
# tp.Topology(gdf, prequantize=10000, toposimplify=10000).to_alt() # 457ms
# count vertices
arcs = topo.to_dict()['arcs']
np.sum([len(arc) for arc in arcs])
1015
from topojson.
Or Jax
from topojson.
Related Issues (20)
- Topology modifies source data
- Topojson bbox should not be transformed when loading Topojson-dict HOT 1
- toposimplify wrongly applied on Topojson data from file
- Reduce decimal places when converting to GeoJSON HOT 2
- Shapely deprecation warnings in topojson 1.3 HOT 5
- Keep geojson properties HOT 6
- Merge multiple layers in a single topojson HOT 5
- 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
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.