question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:10
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jonmmeasecommented, Sep 22, 2018

A geographic heatmap figure factory would be really nice!

2reactions
JiaweiZhuangcommented, Apr 5, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Geographical plotting of maps with Plotly | by Jenny Dcruz
Geographical plotting is a method of displaying data on a global scale as well as for states of a country, often in a...
Read more >
Choropleth maps in Python - Plotly
A Choropleth Map is a map composed of colored polygons. It is used to represent spatial variations of a quantity. This page documents...
Read more >
Import Raster Data in Projected Coordinate Reference System
This example illustrates how to import and display geographic data that contain coordinates in a projected coordinate reference system. In particular, this ...
Read more >
Create Points Tool | Alteryx Help
Fields are Projected Floating Points: The coordinates are displayed in a geographic projection. By default, Designer uses WGS84.
Read more >
fields.pdf - The Comprehensive R Archive Network
A classic use of this function is to depict a vector field. ... with a map projection or a scaling and rotation of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found