-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
to_gdf after topology detection #111
Comments
Thanks for trying this package! And thanks for raising the issue! It took me a long lime to realise that the A quick scan show that Topology(
{'arcs': [[[1.0, 1.0], [2.0, 1.0], [2.0, 0.0]],
[[1.0, 0.0], [0.0, 0.0], [0.0, 1.0]],
[[0.0, 1.0], [0.0, 2.0], [1.0, 2.0], [1.0, 1.0]],
[[1.0, 1.0], [0.0, 1.0]],
[[1.0, 0.0], [2.0, 0.0]],
[[2.0, 0.0], [2.0, -1.0], [1.0, -1.0], [1.0, 0.0]]],
'bbox': (0.0, -1.0, 2.0, 2.0),
'coordinates': [],
'objects': {'data': {'geometries': [{'arcs': [[-4, 0, -5, 1]],
'properties': {'name': 'abc'},
'type': 'Polygon'},
{'arcs': [[2, 3]],
'properties': {'name': 'def'},
'type': 'Polygon'},
{'arcs': [[4, 5]],
'properties': {'name': 'ghi'},
'type': 'Polygon'}],
'type': 'GeometryCollection'}},
'type': 'Topology'}
) Where this behaviour only occurs on
I cannot see why it behaves wrongly here were the other geometries behave normally. For setting up a specific test I suspect the focus should be on this part: https://github.com/mattijn/topojson/blob/master/topojson/utils.py#L155:L160. Thanks again for raising! EDIT: def test_topology_geojson_duplicates():
p0 = wkt.loads('POLYGON ((0 0, 0 1, 1 1, 2 1, 2 0, 1 0, 0 0))')
p1 = wkt.loads('POLYGON ((0 1, 0 2, 1 2, 1 1, 0 1))')
p2 = wkt.loads('POLYGON ((1 0, 2 0, 2 -1, 1 -1, 1 0))')
data = gpd.GeoDataFrame({"name": ["abc", "def", "ghi"], "geometry": [p0, p1, p2]})
topo = tp.Topology(data, prequantize=False)
p0_wkt = topo.to_gdf().geometry[0].wkt
assert p0_wkt == 'POLYGON ((0 1, 0 0, 1 0, 2 0, 2 1, 1 1, 0 1))' |
Thank you for prompt response ! Indeed I should have pointed out the duplicate. Sorry for that ! Thanks also for pointing out where the problem comes from. After some debugging, here is why this fails with this particular geometry : I ended up writing the following (I didn't manage to keep it a one liner) to replace line 155 to 161:
What do you think ? |
Yes, thanks for looking into it. What you propose is a good solution. If you can turn it into a Pull Request, that would be great! |
Fixed by #112 |
Hi @mattijn ! Thank you for your work on topojson, it is much appreciated 👍
I would like to raise the following issue : after computing a topology in which one of the polygons shares arcs with more than one other polygon, the geodataframe that is produced contains a duplicated coordinate for the polygon that is connected to several others. Below the reproducing code :
returns :
array([[0., 1.], [0., 0.], [1., 0.], [2., 0.], [2., 0.], [2., 1.], [1., 1.], [0., 1.]])
This is not an issue visually, but when using the result for further calculation, it can create problems.
The text was updated successfully, but these errors were encountered: