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

start geopandas extension #728

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

knaaptime
Copy link
Contributor

to begin review. The notebook at examples/explore should run through and demonstrate functionality. I need to take a look at how you prefer to test against Maps

@knaaptime
Copy link
Contributor Author

resolves #136

pyproject.toml Outdated
@@ -44,6 +44,7 @@ classifiers = [
cli = ["click>=8.1.7", "pyogrio>=0.8", "shapely>=2"]
geopandas = ["geopandas>=0.13", "pandas>=2", "shapely>=2"]
movingpandas = ["movingpandas>=0.17"]
explore = ["mapclassify>=2.8.1"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can include this in the geopandas extra

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, wasnt sure how you wanted to handle that part. Geopandas itself only has a soft dependency on mapclassify so its only imported when scheme is used; wasn't sure if you wanted to keep it similarly isolated (even though I hadn't structured the import like that)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in that case, maybe it is better to keep it separate. Especially if we move the mapclassify import only within the else clause where it's used.

In that case, it's probably fine to not even define mapclassify in an extra.

Comment on lines 23 to 42
def explore(
self,
column=None,
cmap=None,
scheme=None,
k=6,
categorical=False,
elevation=None,
extruded=False,
elevation_scale=1,
alpha=1,
layer_kwargs=None,
map_kwargs=None,
classify_kwargs=None,
nan_color=[255, 255, 255, 255],
color=None,
wireframe=False,
tiles="CartoDB Darkmatter",
m=None,
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand on what differences (if any) there are with the upstream geopandas.explore method? I think we'd want it to be as similar as possible.

That would be great to include in this docstring.

Additionally, ideally there would be a way to get valid type hinting here, but presumably that won't work if this is added at runtime to the GeoDataFrame instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure happy to add both. In general I tried to keep all possible arguments the same (hence the tiles that uses a str --> class--> str, which isn't ideal but I'm hard conditioned to type tiles='CartoDB Positron') any time I explore.

the one thing I know is different is classification_kwargs used here vs classification_kwds used in geopandas, but I'll switch it to martin's version for compat. Otherwise, any arguments available in explore have the same name. Those that don't map between the two are unique to the backengs, e.g. layer_kwargs here vs style_kwds in vanilla explore

also I generally use numpy docstrings but I think the rest of the packages uses another format, so I should probably update that too

@martinfleis
Copy link

Keep me in the loop. Happy to do a proper review of this from the geopandas perspective once @kylebarron is happy.

from mapclassify.util import get_color_array
except ImportError as e:
raise ImportError(
"you must have the `mapclassify` package installed to use this function"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more clear?

"you must have the `mapclassify` package installed if you pass `classification_kwds`"

pyproject.toml Outdated
@@ -42,9 +42,8 @@ classifiers = [

[project.optional-dependencies]
cli = ["click>=8.1.7", "pyogrio>=0.8", "shapely>=2"]
geopandas = ["geopandas>=0.13", "pandas>=2", "shapely>=2"]
geopandas = ["geopandas>=0.13", "mapclassify>=2.8.1", "pandas>=2", "shapely>=2"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can take out the dependency altogether from here. If someone hits the error they'll be instructed to install it.

highlight=False,
m=None,
):
"""explore a dataframe using lonboard and deckgl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this docstring is exactly the same as the public-facing docstring, you can just write here to refer to the public docstring for parameter information.

):
"""explore a dataframe using lonboard and deckgl

Parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we do use the other docstring format in lonboard (I can't remember which of numpy/google format is which), and it would be good to standardize on that format.

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.

3 participants