Comments (7)
Thanks for raising the issue. Quick look. I'm trying to break it down to isolate the issue:
import geopandas as gpd
from shapely import geometry
import topojson as tp
def visz_arcs(topo):
gdf = gpd.GeoDataFrame(geometry=[geometry.LineString(arc) for arc in topo.to_dict()['arcs']])
gdf.plot(cmap='Dark2')
pth = '/Users/mattijnvanhoek/Downloads/testcase_topojson/testcase_topojson.gpkg'
gdf = gpd.read_file(pth)
# when `shared_coords` set to `True`, a path is considered shared when
# all coordinates appear in both paths (`coords-connected`).
topo = tp.Topology(gdf, prequantize=False, shared_coords=True)
visz_arcs(topo)
# when `shared_coords` set to `False` a path is considered shared when
# coordinates are on the same path (`path-connected`).
# the path-connected strategy is more 'correct', but slower. Default is `True`.
topo = tp.Topology(gdf, prequantize=False, shared_coords=False)
visz_arcs(topo)
With shared_coords=True
it seems there is some overlap with some line strings. These linestrings are not splitted and recognised as duplicate arcs.
This behaviour above is on master version. Not sure if the same happens in latest release.
It would be great if we can isolate it even further. Maybe it is possible to bring it back to 2 or 3 linestrings?
Currently the following gives to many output
from topojson.core.cut import Cut
cut = Cut(gdf, options={'prequantize':False, 'shared_coords':True})
cut.to_svg(separate=True, include_junctions=True)
from topojson.core.dedup import Dedup
dedup = Dedup(gdf, options={'prequantize':False, 'shared_coords':True})
dedup.to_svg(separate=True, include_junctions=True)
from topojson.
With shared_coords=False
it seems OK, but what about here?
Hm, thinking about it. I think that is alright as well. A single point on a line is not a shared path and therefor not seen as a junction.
Ah, the green and pink arcs are separated because probably there is the start/end coordinate of the polygon. With a perfect topology these two arcs are combined again.
from topojson.
Probably you know this resource already, but I Just found this really interesting explanation that clarified for me at least what to expect: https://bost.ocks.org/mike/topology/
from topojson.
Yes. I use the same wording/phases to create a certain synergy, but the implementations are different.
from topojson.
See also https://mattijn.github.io/topojson/how-it-works.html
from topojson.
Some answers:
- I noticed the issue in the release version and afterwards tested it on master as well to be sure it wasn't fixed yet in master.
- I tried with
shared_coords=False
as well, and it seemed better but I still noticed issues. The performance is 3 times worse though, and the functional advantage offered byshared_coords=False
is not relevant for my use case, so I focused onshared_coords=True
for the moment
I think the problem at least starts in the 'join' phase: there is an issue in how the junctions are determined, as there are junctions in the middle of lines. Possibly there are also missing junctions which could explain the overlapping parts.
from topojson.
I have been looking deeper into it based on your feedback and it seems I misunderstood the impact of shared_coords=True
. Both the overlapping pieces and the odd way the "red" line is split can be explained by this. Not sure if this behaviour is really wanted and/or "by design", but my data definitely needs shared_coords=True
to get decent results.
As I stated before I also saw issues when I tried shared_coords=True
but they might indeed be explained by the problem you raise here:
Ah, the green and pink arcs are separated because probably there is the start/end coordinate of the polygon. With a perfect topology these two arcs are combined again.
I'll have a look if I can add support to combine those arcs again...
from topojson.
Related Issues (20)
- 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
- 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
- Converting TopoJson to a GeoJSon object_name not changing 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.