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

revise set_lines_ids with cKDTree #808

Closed
wants to merge 3 commits into from
Closed

Conversation

davide-f
Copy link
Member

@davide-f davide-f commented Jul 23, 2023

Closes #806

Changes proposed in this Pull Request

This PR revise the implementation of set_lines_ids with cKDTree.
Performance speed increases by a factor 10 in the Nigeria case (0.12s vs 1.2s in the standard implementation).
For US, 26s are required vs about 12min in the previous formulation.
Performance speed is expected to be significant with the problem size.

Checklist

  • I consent to the release of this PR's code under the AGPLv3 license and non-code contributions under CC0-1.0 and CC-BY-4.0.
  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and doc/requirements.txt.
  • Changes in configuration options are added in all of config.default.yaml and config.tutorial.yaml.
  • Add a test config or line additions to test/ (note tests are changing the config.tutorial.yaml)
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes, including reference to the requested PR.

@davide-f davide-f marked this pull request as draft July 23, 2023 14:49
@davide-f
Copy link
Member Author

@mnm-matin FYI :)

@davide-f davide-f added this to the Version 1.0 milestone Jul 23, 2023
@davide-f davide-f marked this pull request as ready for review July 23, 2023 15:11
@davide-f
Copy link
Member Author

An alternative implementation using only geopandas may be used: https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.sjoin_nearest.html#geopandas.GeoDataFrame.sjoin_nearest
though not sure if it may be more performant

@mnm-matin
Copy link
Member

@davide-f the geopandas spatial index uses cKDTree under the hood, so either implementation is equivalent. The geopandas sjoin hides the complexity and reduces per-script dependancies.

@davide-f
Copy link
Member Author

Closing in favor of #845

@davide-f davide-f closed this Dec 18, 2023
@davide-f davide-f deleted the revise_set_lines_ids branch December 18, 2023 22:32
@davide-f davide-f restored the revise_set_lines_ids branch December 18, 2023 22:32
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

Successfully merging this pull request may close these issues.

Improve performances of set_lines_ids with cKDTree
2 participants