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
ENH: add greedy (topological) coloring #61
Conversation
sweet, thanks! Others may have opinions here, but my quick responses would be
|
@knaaptime I had no idea |
I have marked most of the tests with pytest.xfail as there is no rtree on CI. That would be ideal to get from conda-forge, but apart from numba everything now comes from pip (I tried to get rtree but it resulted in error https://travis-ci.org/github/pysal/mapclassify/builds/673150902). Do you have a preference how to go around that? We may even keep it xfailing if this functionality will eventually come from |
we should just install everything from conda (like we do elsewhere) and avoid pip on CI altogether |
Just to confirm that I'm happy to relicense any part of this I've written to whatever license works for your needs. Even WTFPL if you want. |
@nyalldawson |
I have opened a small PR in libpysal pysal/libpysal#280 extending functionality of existing |
Thanks @sjsrey. I have removed the explicit license from the file as it will inherit the license of the whole package now. |
Implementation of
greedy
package for topological (greedy) colouring of GeoPandas GeoDataFrames. This is the first draft to have something concrete to work on. It is essentially copy&paste of the original code from https://github.com/martinfleis/greedy with few changes here and there to mention thatgreedy.greedy
is nowmapclassify.greedy
and to make deps optional. Three notebooks used as docs for greedy are now merged to one to become part of Pysal Notebooks.Apart from the obvious questions whether this is the optimal way how to implement it within mapclassify, there are some additional which need to be resolved.
License. The core of
_balanced
algorithm is ported from QGIS where it is licensed under GPL-3.0. To make my life easier, I have used the same license for whole greedy. We need to figure out how to resolve this as GPL-3.0 is not compatible with BSD-3-Clause afaik. I don't mind for my code and @nyalldawson mentioned that he's also willing to relicense that part coming from QGIS if needed.Terminology. QGIS uses topological colouring, I am using mostly greedy colouring. What do you prefer? It would be good to have continuity from existing
greedy
, but I don't see it as a crucial thing if we decide that topological coloring is a preferred way. We can changegreedy
to something else._geos_sw
is a function which generates libpysal.W object based on intersection between objects or their buffered versions. Naturally it is significantly slower that Queen or Rook weights (but that will get better with pygeos within GeoPandas eventually), but it does not require topological correctness of dataset and allows tolerance (i.e. buffer). I feel that the right place for it could belibpysal
as it may be useful elsewhere apart from greedy colouring. Should we implement it here with a note that it should go to libpysal and remove it from here once it is released there?For details on what
greedy
brings, see https://martinfleis.github.io/greedy/.xref pysal/splot#94, geopandas/geopandas#1165