Skip to content
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

BUG: Topology.to_gdf should keep the original index #164

Closed
Zeroto521 opened this issue Aug 11, 2022 · 2 comments
Closed

BUG: Topology.to_gdf should keep the original index #164

Zeroto521 opened this issue Aug 11, 2022 · 2 comments

Comments

@Zeroto521
Copy link
Contributor

Zeroto521 commented Aug 11, 2022

The index of returning Topology.to_gdf is not equal to the inputting one.

import geopandas as gpd

from topojson import Topology

df = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres")).query(
    'continent == "Africa"'
)

result = Topology(df, 1).to_gdf(crs=df.crs)
print(df.index)
# Int64Index([  1,   2,  11,  12,  13,  14,  15,  25,  26,  48,  49,  50,  51,
#              52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,  64,
#              65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  78,  80,
#              81,  82, 154, 162, 163, 164, 165, 166, 167, 168, 169, 176],
#            dtype='int64')
print(result.index)  # should be `df.index`
# RangeIndex(start=0, stop=51, step=1)

Package versions

  • geopandas 0.11.1
  • geopandas-base 0.11.1
  • topojson 1.4
@mattijn
Copy link
Owner

mattijn commented Aug 11, 2022

Thanks for raising the issue. Please see #165 where I've implemented this enhancement as feature. Will that work for you?

@Zeroto521
Copy link
Contributor Author

Thanks for fixing that problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants