Skip to content

Figure factory: Plot a scalar field with geographical coordinates on map with projection #715

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
ghost opened this issue Mar 16, 2017 · 13 comments
Labels
feature something new P3 backlog

Comments

@ghost
Copy link

ghost commented Mar 16, 2017

I have an array of global temperatures and associated longitude and latitude coordinates arrays. I would like to plot the temperatures as a heatmap on a map with custom projection and showing coastlines.
A working code example using matplotlib is:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

f, ax = plt.subplots(subplot_kw={'projection': ccrs.Robinson()})
p = ax.pcolormesh(longitude, latitude, temperature, cmap='RdBu_r', transform=ccrs.PlateCarree())
ax.coastlines()
f.colorbar(p, orientation='horizontal')

The output figure from code block above is (data available here):
map

At the moment I was only able to use plotly for a simple heatmap with the following code:

from plotly.offline import iplot
import plotly.graph_objs as go

layout = go.Layout(geo={'projection': {'type': 'robinson'}})
data = go.Heatmap(x=longitude, y=latitude, z=temperature)

fig = go.Figure(data=[data], layout=layout)
iplot(fig)

As next figure shows, main issues are:

  • the projection is not working;

  • no coastlines are shown.
    heatmap

@Balinus
Copy link

Balinus commented Feb 22, 2018

Would also love something similar!

@empet
Copy link

empet commented Feb 22, 2018

You can plot both heatmap and contour plots on maps. Take a look here: https://plot.ly/~Dreamshot/9147 or visit this user (Dreamshot) Plotly profile for more examples.

@Balinus
Copy link

Balinus commented Feb 22, 2018

Thanks! Will take a look :)

@Balinus
Copy link

Balinus commented Feb 23, 2018

Although it does not seem to support mapping per se. I mean, the data are on a lat-lon coordinates, but what if we want to change the projection? I don't see a proper support for maps right out of the box (or at least without creating a unique map for each use case).

@JiaweiZhuang
Copy link

This blog should help: How to Create 2D and 3D Interactive Weather Maps in Python and R

@jonmmease
Copy link
Contributor

A geographic heatmap figure factory would be really nice!

@jonmmease jonmmease changed the title Feature request: Plot a scalar field with geographical coordinates on map with projection Figure factory: Plot a scalar field with geographical coordinates on map with projection Sep 22, 2018
@zxdawn
Copy link

zxdawn commented Oct 26, 2021

How about the progress here? It seems geoviews supports this function, but that's sometimes slow.
Similar question is on the forum.

@pedroaugustosmribeiro
Copy link

I also would like to plot any scallar (numpy array, xarray, etc) with a projeceted basemap in plotly just like is done on matplolib+cartopy integration

@Balinus
Copy link

Balinus commented Oct 31, 2022

I am currently using GeoMakie.jl (https://github.com/MakieOrg/GeoMakie.jl). Works really well!

@pedroaugustosmribeiro
Copy link

I am currently using GeoMakie.jl (https://github.com/MakieOrg/GeoMakie.jl). Works really well!

Nice, however it's in Julia. Is it possible to mix it inside a Python Plotly Dash app?

@Balinus
Copy link

Balinus commented Dec 5, 2022

I am currently using GeoMakie.jl (https://github.com/MakieOrg/GeoMakie.jl). Works really well!

Nice, however it's in Julia. Is it possible to mix it inside a Python Plotly Dash app?

Not sure. Using Python inside Julia is easy, the other way around is more difficult in my experience. This is actually the reason why I use Julia : this gives me access to Julia and 100% of Python's ecosystem.

@g-voelker
Copy link

Of course, there are other methods out there, for Python cartopy stays the library of choice when it comes to map-based plots. A speedy and interactive data visualization tool stays, however, a rare feat.

I support the request for the feature and think it would make a good unique selling point for plotly in the geosciences and adjacent communities.

@g-voelker
Copy link

A quick side remark: All scripts implementing the requested functionality (see above in the thread) depend on basemap which has reached EoL and names cartopy as a recommended replacement. Thus there is currently no example of an efficient geospatial data representation in plotly.

I will no further bump this thread, but I'd like to stress that I would really like the feature and hope that it isn't just me.

@gvwilson gvwilson self-assigned this Jun 10, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added feature something new P3 backlog and removed ♥ NEEDS SPON$OR labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

9 participants