Search code examples
pythonmatplotlibmatlab-figureheatmapcontour

Plot data in different locations as a contour map


I have data for many locations, I want to plot these data in different locations as a contour map or any different style. Here is an example of data I have:

    Date    Lat Lon Concentration
    1950    2   2   5

    Date    Lat Lon Concentration
    1950    2   2.25    7

    Date    Lat Lon Concentration
    1950    2   2.5 8
    .           
    .           
    .           

I'd like to plot a heat map or contour map that shows each location's concentration.

Any suggestion?


Solution

  • You can use the plot_google_maps function from the MATLAB file exchange here. This will create a plot with a worldmap as background zoomed in to the extend of your Lat and Lon coordinates. There, you can plot a scatter plot into with a colorbar.

    % extract your latitude, longitude data from your input file (which I do not have)
    % lat = <your latitude data>
    % lon = <your longitude data>
    
    % Your z-values for the heatmap (Concentration). I used random number here
    concentration = rand(size(lat));
    
    % Plot a scatter plot with a colorscaling on concentration
    scatter(lat,lon,50,concentration,'o','filled')
    
    % Add colorbar
    colorbar
    
    % Add google map section of your lat and lon data as background on the plot
    plot_google_map
    

    This gives something like that

    enter image description here