Skip to content

Missing geometry from cells_dataframe_to_geodataframe with non-sequential index #76

@cas--

Description

@cas--

Encountered a rather puzzling bug where a non-sequential index for a dataframe causes a problem when converting cells to geodataframe resulting in missing geometry for most of the cells.

uvx --with h3ronpy[pandas] python

from h3ronpy.pandas.vector import cells_dataframe_to_geodataframe
import pandas as pd
df = pd.DataFrame({'cell': {2: 630950036828342783, 19: 630950036828350975, 38: 630950036828390911, 55: 630950036828391423}})
cells_dataframe_to_geodataframe(df)
                  cell                                           geometry
2   630950036828342783  POLYGON ((-3.42058 50.63746, -3.42072 50.63743...
19  630950036828350975                                               None
38  630950036828390911                                               None
55  630950036828391423                                               None

Resetting the index is a workaround for the issue

cells_dataframe_to_geodataframe(df.reset_index(drop=True))
0  630950036828342783  POLYGON ((-3.41817 50.6377, -3.41831 50.63767,...
1  630950036828350975  POLYGON ((-3.41884 50.63765, -3.41898 50.63762...
2  630950036828390911  POLYGON ((-3.42058 50.63746, -3.42072 50.63743...
3  630950036828391423  POLYGON ((-3.42048 50.6373, -3.42062 50.63727,...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions