0

I am trying to create a map that plots the intensity of wind speed from satellite data. The data consists of longitude, latitude, and the wind speed intensity. The longitude/latitude plots the locations (done), while the speed gives each point a color based on the value of the wind data.

As of now, all points are colored blue (look at script).

The data frame looks like this:

    lon    lat   wind_speed
1   13.0   75.3  23.5
2   12.9   25.2  23.7
3   12.7   75.2  24.2
4   12.6   75.1  24.6
           ...

The result should look something like this: https://gyazo.com/118d4785b49c861096f93799f60a0622

here is my current code:

import os
import numpy as np
from netCDF4 import Dataset
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

... #ncdump, this is from a file in my computer


#variables for map in array form
wind_speed_array =nc_fid.variables['wind_speed_alt']
lats=nc_fid.variables['lat'][:]
lons =nc_fid.variables['lon'][:]


fig = plt.figure()
fig.autofmt_xdate()
m = Basemap(projection='mill',resolution='l')
m.drawcoastlines()
m.drawcountries()
plt.title("time series plot: wind speed")

x,y=m(lons,lats)
cs=m.scatter(x,y,wind_speed_array,color='blue')

plt.show()

Currently, I have a map with all the points, but they are all colored blue. How would I make the points colored based on their value like in the example picture?

Bob
  • 115
  • 10
  • Have you tried to use `seaborn`'s `scatterplot` and pass the values to `hue` argument? I think it would be easier that way. – Xiaoyu Lu Jan 02 '19 at 20:25
  • 1
    The command would be `m.scatter(x, y, c=wind_speed_array)`. – ImportanceOfBeingErnest Jan 02 '19 at 20:38
  • I replaced the command with cs=m.scatter(x,y,c=wind_speed_array). However, I got an error that, 'c' argument has 11130 elements, which is not acceptable for use with 'x' with size 5565, 'y' with size '5565'. – Bob Jan 02 '19 at 20:47

1 Answers1

0

You need to have colormap as your input argument color and I think LinearColorMap should work nicely.

A colorbar will help you get the legend bar like the one at the bottom of your example.

Boon
  • 56
  • 7