Skip to content

start geopandas extension #728

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

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

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

@martinfleis
Copy link

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

@knaaptime
Copy link
Contributor Author

i think this should be ready, though I'm not the best with type hints or google docstrings

@kylebarron
Copy link
Member

Can you check why pre-commit is still failing? You should be able to run it locally with

pip install pre-commit
pre-commit run --all-files

@kylebarron
Copy link
Member

@martinfleis do you have any comments on this PR?

I'd like to get in #753, which in general raises the code quality of the code base, and then ensure that this PR meets that bar as well.

Copy link

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

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

Looks great! Just a few minor notes.

Comment on lines 56 to 58
elevation : Name of column on the dataframe used to extrude each geometry or
an array-like in the same order as observations. Defaults to None.
extruded : Whether to extrude geometries using the z-dimension.

Choose a reason for hiding this comment

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

I probably don't follow here. Shouldn't extruded be automatically True when elevation is provided? Like the two are tied together, no? Or can I use extruded without elevation? What does it extrude on, then, Z coordinate? How?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i agree this is a little awkward. There's probably no need for the bool, though I was just trying to follow the viz/Layer API which treats them separately. Happy to go with consensus here.

Another small wrinkle is that sometimes in GIS or CAD software (IIRC anyway) 'elevation' sometimes refers to the height beneath the polygon, e.g. so you can drop the extruded poly onto a DEM for things like viewsheds. In that case I want to say this parameter is called 'extrusion_height' or something? No real opinion here, just something to consider in case folks are coming from that world

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i removed the bool so that its turned on automatically if elevation is passed

@knaaptime
Copy link
Contributor Author

fixed annotations in the notebook so im not sure what the lingering failure is

@knaaptime
Copy link
Contributor Author

copiolt thinks the failure is a caching issue (apparently), so i'd guess it will pass if re-run on its own

@kylebarron kylebarron added this to the 0.11 milestone Mar 24, 2025
@knaaptime
Copy link
Contributor Author

looks like maybe some other parts of the stack are moving at the moment, but let me know if there's anything I can do to help move this forward :)

Comment on lines +30 to +34
def explore( # noqa: PLR0913
self,
column: str | None = None,
cmap: str | None = None,
scheme: str | None = 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 we make some of these parameters keyword-only? Perhaps change to

Suggested change
def explore( # noqa: PLR0913
self,
column: str | None = None,
cmap: str | None = None,
scheme: str | None = None,
def explore( # noqa: PLR0913
self,
column: str | None = None,
*,
cmap: str | None = None,
scheme: str | None = None,

so that everything after column can only be passed as a named kwarg?

Comment on lines +117 to +139
def _dexplore( # noqa: C901, PLR0912, PLR0913, PLR0915
gdf, # noqa: ANN001
*,
column, # noqa: ANN001
cmap, # noqa: ANN001
scheme, # noqa: ANN001
k, # noqa: ANN001
categorical, # noqa: ANN001
elevation, # noqa: ANN001
elevation_scale, # noqa: ANN001
alpha, # noqa: ANN001
layer_kwargs, # noqa: ANN001
map_kwargs, # noqa: ANN001
classification_kwds, # noqa: ANN001
nan_color, # noqa: ANN001
color, # noqa: ANN001
vmin, # noqa: ANN001
vmax, # noqa: ANN001
wireframe, # noqa: ANN001
tiles, # noqa: ANN001
highlight, # noqa: ANN001
m, # noqa: ANN001
) -> Map:
Copy link
Member

Choose a reason for hiding this comment

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

It's not ok to ignore all of these errors. At a minimum we need every function parameter and return type to be correctly typed so that we can catch internal type errors.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of defining this as a separate function; put this implementation inside of LonboardAccessor.explore. There's not really any reason to have this defined as a standalone function?

return new_m


def _get_categorical_cmap(categories, cmap, nan_color, alpha): # noqa: ANN001, ANN202
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be typed.

from matplotlib import colormaps
except ImportError as e:
raise ImportError(
"this function requires the `lonboard` package to be installed",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"this function requires the `lonboard` package to be installed",
"this function requires the `matplotlib` package to be installed",

elevation, # noqa: ANN001
elevation_scale, # noqa: ANN001
alpha, # noqa: ANN001
layer_kwargs, # noqa: ANN001
Copy link
Member

Choose a reason for hiding this comment

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

It looks like layer_kwargs is something you're adding that doesn't exist in the upstream GeoDataFrame.explore. In that case, you should follow the same behavior as in viz and use the same parameters:

scatterplot_kwargs: ScatterplotLayerKwargs | None = None,
path_kwargs: PathLayerKwargs | None = None,
polygon_kwargs: PolygonLayerKwargs | None = None,
map_kwargs: MapKwargs | None = None,

This will also fix your type hinting below:
image

Copy link
Member

@kylebarron kylebarron left a comment

Choose a reason for hiding this comment

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

Sorry that this has sat for a while without a review. I have too many projects and haven't dedicated time to Lonboard recently.

Because I have too many projects, I also have a high bar for contributions so that they don't grow to become a larger maintenance burden in the future.

There's still a decent amount of work here before it's review ready. In particular, there should be virtually no type: ignore statements.

@kylebarron kylebarron removed this from the 0.11 milestone Jun 17, 2025
@knaaptime
Copy link
Contributor Author

no sweat! thanks for the comments

right there with you and similarly spread thin :). Static typing is pretty extraneous in most of my projects so not very practiced; will take another pass, or several

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