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

Improve hover for geometries - make it less likely to fail #1055

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

jsignell
Copy link
Member

@jsignell jsignell commented Apr 6, 2023

Closes #842
I am unsure of how much of this PR overlaps with holoviz/holoviews#5325.

MRE from #842 (slightly augmented to include by="reference_time")

import geopandas
import hvplot.pandas

json_str = '{"type": "FeatureCollection", "features": [{"id": "292", "type": "Feature", "properties": {"reference_time": "2021-08-03T06:00:00"}, "geometry": {"type": "Polygon", "coordinates": [[[6.734387964482268, 50.096981436429836], [6.715702760798321, 50.08350087669019], [6.7164606556881665, 50.07500090230046], [6.726932700709735, 50.06899131283367], [6.727498990205583, 50.062616788193964], [6.730988279570088, 50.06061342371476], [6.7311767879985, 50.05848865569604], [6.748616494592647, 50.048470246593965], [6.749553435189103, 50.0378472878539], [6.7565245571179045, 50.033839329129954], [6.822494229902199, 50.036222772078176], [6.829457117826622, 50.03220914103082], [6.832755487784024, 50.032326768682196], [6.836236195568452, 50.03031965546154], [6.839534418239325, 50.03043703037027], [6.843014579155103, 50.02842967525436], [6.846312654459997, 50.02854679744998], [6.849792268503478, 50.026539200507266], [6.853090196362978, 50.026656070019335], [6.856569263530571, 50.024648231318345], [6.882952088134839, 50.02557774446169], [6.889189529279116, 50.03005826409537], [6.888113617274682, 50.04280701271642], [6.884634555008016, 50.04481630967492], [6.8747356652759315, 50.04446880452035], [6.8712557178674984, 50.04647759882098], [6.8646562244125935, 50.04624505628612], [6.861175560726028, 50.048253478263526], [6.854575813313595, 50.04802018550571], [6.847612674584511, 50.05203617315432], [6.847430905745282, 50.05416109906186], [6.843948557379587, 50.056168944871104], [6.843766557088876, 50.05829391731779], [6.833316605440537, 50.06431684307392], [6.83001537252634, 50.06419921302388], [6.826531128284592, 50.066206501150646], [6.806723163146417, 50.065497367264776], [6.799751515201596, 50.069510039897715], [6.799566902060483, 50.07163509569316], [6.789105952186076, 50.077653323156746], [6.788550085538567, 50.0840288255632], [6.785061709927709, 50.086034734508154], [6.784876167120653, 50.088159975675374], [6.781387200638471, 50.09016579161379], [6.781201425169829, 50.092291079083346], [6.777711867667758, 50.094296801962315], [6.777525859439406, 50.09642213571793], [6.77403571076884, 50.098427765484495], [6.734387964482268, 50.096981436429836]]]}}, {"id": "329", "type": "Feature", "properties": {"reference_time": "2021-08-03T06:15:00"}, "geometry": {"type": "Polygon", "coordinates": [[[6.53500332673663, 50.17262838814129], [6.525676395793689, 50.165864441490726], [6.509130066483161, 50.165217619771184], [6.493598140164972, 50.15393999616791], [6.490290012794701, 50.15380969662393], [6.487184983165786, 50.151553827645586], [6.483877092942987, 50.151423292112206], [6.477668602593298, 50.1469110968444], [6.477872177168287, 50.14478575952954], [6.474768669293165, 50.142529583182], [6.474972387017253, 50.140404309639585], [6.468766845311061, 50.135891799690036], [6.452234991265688, 50.135234543767545], [6.449133859035186, 50.1329776075923], [6.449954293080332, 50.12447741050391], [6.443754499017571, 50.119963601072335], [6.440449599993195, 50.119831480170184], [6.437350486271928, 50.117574347547794], [6.434045824577542, 50.11744199108877], [6.430947304193949, 50.115184668906], [6.4276428798783325, 50.115052076929956], [6.424544952781937, 50.11279456525802], [6.421240765893827, 50.11266173780486], [6.421447405298261, 50.11053697719101], [6.415253448962403, 50.10602157197326], [6.415460396331883, 50.10389691192589], [6.412364153209042, 50.101639131494146], [6.409061010457461, 50.101505861479545], [6.405965360262447, 50.099247891817576], [6.406172804999734, 50.09712334179774], [6.403077699809985, 50.09486533258377], [6.406587622735568, 50.092874323519545], [6.406794995742371, 50.0907498552632], [6.41030432603753, 50.088758750082896], [6.413606331103893, 50.08889196357895], [6.417115116616857, 50.08690061275905], [6.433624670504715, 50.08756418677074], [6.452208535577216, 50.101104117299926], [6.458815082702433, 50.10136733427171], [6.461914147828928, 50.10362349560114], [6.465217670042701, 50.10375480739412], [6.4683173279463855, 50.10601077904516], [6.468113416590205, 50.108135588575635], [6.480516509589828, 50.1171588550765], [6.483821311675101, 50.11728948785017], [6.48692324762389, 50.11954499954339], [6.506753830987399, 50.120325544782304], [6.516065757468713, 50.12708957980573], [6.519371575991884, 50.127218901978026], [6.522476524780929, 50.129473313114914], [6.529088657857204, 50.129731363130404], [6.535300548774286, 50.13423950078656], [6.5340989899325645, 50.146991888717444], [6.537206508245576, 50.149246060243634], [6.537006334657516, 50.15137159007232], [6.540114400713651, 50.1536257208377], [6.539714318626019, 50.15787693505321], [6.542823099854781, 50.16013106138122], [6.541823326839114, 50.170759755944204], [6.538313303264706, 50.17275704375211], [6.53500332673663, 50.17262838814129]]]}}]}'
small_dataset = geopandas.read_file(json_str)

small_dataset.hvplot(geo=False, groupby="reference_time") # works but has a weird empty hover
small_dataset.hvplot(geo=True, groupby="reference_time") # does not work
small_dataset.hvplot(geo=False, by="reference_time") # does not work
small_dataset.hvplot(geo=True, by="reference_time") # does not work

With this PR:
image

@hoxbro
Copy link
Member

hoxbro commented Apr 7, 2023

I just tested your PR and the current main with the latest main on Holoviews and Geoviews:

code hvplot main #1055
geo=False + groupby Works but weird hover Works no hover
geo=True + groupby Errors Works no hover
geo=False + by Works with hover Works no hover
geo=True + by Works with hover Works no hover

I will cut a dev release for holoviews and geoviews, so you don't have to second-guess your great work.

@jsignell
Copy link
Member Author

jsignell commented May 1, 2023

Is there anything that I need to change on this one?

@maximlt
Copy link
Member

maximlt commented Jun 2, 2023

I'm sure the code handling these multiple options (hover + geom + by/groupby ...) has some other weaknesses and could be improved but this requires a deeper dive. Thanks for this PR as it indeed makes things less likely to fail which is a lot better!

@maximlt maximlt merged commit d32e130 into holoviz:main Jun 2, 2023
@jsignell jsignell deleted the geo-hover branch June 2, 2023 14:12
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.

Plot a time-dependent series of geographic polygons from GeoDataframe using hvplot and groupby
3 participants