Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add latitude & longitude mercator support#14656

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
muendlein wants to merge11 commits intobokeh:branch-3.9
base:branch-3.9
Choose a base branch
Loading
frommuendlein:add_wgs84_axis

Conversation

@muendlein
Copy link
Contributor

@muendleinmuendlein commentedOct 1, 2025
edited
Loading

Usage:
p = figure(x_range=(-30, 30), y_range=(-40, 40), x_axis_type="mercator_lon", y_axis_type="mercator_lat")

@codecov
Copy link

codecovbot commentedOct 1, 2025
edited
Loading

Codecov Report

❌ Patch coverage is80.76923% with5 lines in your changes missing coverage. Please review.
⚠️ Pleaseupload report for BASE (branch-3.9@db2574a).Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff              @@##             branch-3.9   #14656   +/-   ##=============================================  Coverage              ?   91.82%           =============================================  Files                 ?      288             Lines                 ?    20786             Branches              ?        0           =============================================  Hits                  ?    19086             Misses                ?     1700             Partials              ?        0
🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@muendleinmuendlein added this to the3.9 milestoneOct 1, 2025
Comment on lines +660 to +663
case"mercator_lon":
returnnewLinearScale()
case"mercator_lat":
returnnewMercatorLatitudeScale()
Copy link
Member

Choose a reason for hiding this comment

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

Offhand this seems backwards to me? latitudes are always evenly spaced apart, but the distance between longitude lines varies depending on latitude. I would expect a linear scale to work for latitude butnot to work for longitude. I haven't thought about this in some years though, maybe you can walk me through it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

What you are describing is true for a sphere/ellipsoid, however the map will be shown in 2D using the web mercator projection (this is where the scales matter). In the web mercator projection the distance between longitude is independent of the latitude which allows for 2D view in the first place. Of course in other to "keep" the proportion the latitude will not behave linearly.

constlat_proj_y=lat_proj_end-lat_proj_range*(sy-y0)/height
const[,lat]=wgs84_mercator.invert(0,lat_proj_y)
returnlat
}
Copy link
Member

Choose a reason for hiding this comment

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

The dimension switching here is just in case someone wants to put latitudes on the x axis? I actually think we might be better off finding some way to make that impossible at the API level. i.e. non-sensical things should not be easy to spell

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes more or less this is just for completeness here. I'm totally okay with outputting a warning in this case as I cannot think about scenario where this is needed.
I agree that this should be caught on a higher level.

@bryevdv
Copy link
Member

I left a few initial comments. I am not sure I thrilled about making users explicitly coordinate

x_axis_type="mercator_lon", y_axis_type="mercator_lat"

It seem like it would be super easy for users to supply these backwards.

I had always previously envisioned this as an input and formatting issue... i.e. we'd keep the existing mercator machinery always working in terms of meters (northings and eastings) but make it so that "lat/lon" inputs were understood and would set an (overrideable) config automatically.

@muendlein
Copy link
ContributorAuthor

I left a few initial comments. I am not sure I thrilled about making users explicitly coordinate

x_axis_type="mercator_lon", y_axis_type="mercator_lat"

It seem like it would be super easy for users to supply these backwards.

I had always previously envisioned this as an input and formatting issue... i.e. we'd keep the existing mercator machinery always working in terms of meters (northings and eastings) but make it so that "lat/lon" inputs were understood and would set an (overrideable) config automatically.

I agree that this is certainly not a good solution. However I'm not sure about other good options that help with knowing what data to expect. Do you think about this config as an additional keyword argument of the figure class describing the data coordinate system?
Setting this config automatically and reliable based on the data is a bit tricky. Of course the lat/lon limits are much smaller compared to the meter limits however in edge cases they will overlap. Additionally this is also not only about the data but also the range, as they might also contract themselves. Realistically I think this requires switching to lat/lon as the default input while trying to understand if data input or range is in meters. As far as I know most real world data deals with lat/lon values instead of meters from the web mercator projection.
I also thought about keeping the mercator machinery in meter/untouched but as you can see with I decided against it (at least partially, tile fetching is still done completely with meters). If I understand your point correctly, you have transformation of the data in mind instead of the transformation of the axis/scale (as in this PR)? I think the former is much more complex and will make debugging a nightmare.

@bryevdv
Copy link
Member

ping@philippjfr@jbednar etc for geoviews thoughs.

@ahuang11
Copy link
Contributor

ahuang11 commentedOct 7, 2025
edited
Loading

Currently the mercator axis expects data as web mercator coordinates (EPSG: 3857). Most real world datasets are however available as lat-long coordinates (EPSG: 4326) and therefore cannot be used directly.

I'd love to see this natively supported in Bokeh! Wondering the reason behind naming itmercator_lon instead oflon, e.g.
p = figure(x_range=(-30, 30), y_range=(-40, 40), x_axis_type="lon", y_axis_type="lat")

Dumb question, but does this allow mixing mercator tiles with lon/lat data? i.e. would I be able to get away with using lon/lat data in this without ll2en (lon_lat_to_easting_northing) called? I suspect not?

https://examples.holoviz.org/gallery/ship_traffic/ship_traffic.html#us-ais-vessel-traffic-data-jan-2020

If I understand your point correctly, you have transformation of the data in mind instead of the transformation of the axis/scale (as in this PR)? I think the former is much more complex and will make debugging a nightmare.

Oh I see. I think this is still useful.

@muendlein
Copy link
ContributorAuthor

Currently the mercator axis expects data as web mercator coordinates (EPSG: 3857). Most real world datasets are however available as lat-long coordinates (EPSG: 4326) and therefore cannot be used directly.

I'd love to see this natively supported in Bokeh! Wondering the reason behind naming itmercator_lon instead oflon, e.g.p = figure(x_range=(-30, 30), y_range=(-40, 40), x_axis_type="lon", y_axis_type="lat")

There is no strong reason behind this. Based on the previous comment the API is still undecided anyway.

Dumb question, but does this allow mixing mercator tiles with lon/lat data? i.e. would I be able to get away with using lon/lat data in this without ll2en (lon_lat_to_easting_northing) called? I suspect not?

https://examples.holoviz.org/gallery/ship_traffic/ship_traffic.html#us-ais-vessel-traffic-data-jan-2020

If I understand your point correctly, you have transformation of the data in mind instead of the transformation of the axis/scale (as in this PR)? I think the former is much more complex and will make debugging a nightmare.

Oh I see. I think this is still useful.

@ahuang11 My wording was probably not precise here. With "the data" I was basically referring to any data except for tile data as the latter is handled internally anyway. Therefore this PR indeed targets to support both tiles as well as "external" coordinate data. The idea is to get rid of the upfront data conversions.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bryevdvbryevdvbryevdv left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.9

Development

Successfully merging this pull request may close these issues.

Add support for latitude & longitude data when using a mercator axis

3 participants

@muendlein@bryevdv@ahuang11

[8]ページ先頭

©2009-2025 Movatter.jp